lacunary - Mathnotes

Simple Example

Digit Classification

Let's talk about an example. We have 28×28 pixel greyscale input image and we want to predict which digit of 0-9 it is.

Each of our pixels are represented by a value from 0 to 255 representing the intensity of the greyscale pixel, with 0 being black and 255 being white.

At the most basic level, we want to make a function

Fβ:M(Z255)24,24→Z10

i.e. Fβ takes in a 24×24 matrix of integers between 0 and 255 and outputs an integer between 0 and 9, the predicted digit represented by the image.

As A Neural Network

Let's start by defining a neuron.

Definition: Neuron \@{neuron}

In a neural network, a neuron N is a computation unit that takes n input values, applies an affine transformation, then a typically non-linear activation function, and returns a single value.

That is, it is a function of the form

N:Rn→R,N(x)=ϕ(w⋅x+b),

where

  • n is the number of inputs to the neuron
  • w∈Rn is a vector of weights,
  • b∈R is a bias value, and
  • ϕ:R→R is an activation function.
Referenced by (2 direct)

Direct references:

Definition: Layer \@{layer}

A layer in a neural network is a collections of neurons that operate in parallel on the same input vector.

A layer with nℓ−1 inputs and nℓ neurons defines a function

Fℓ:Rℓ−1→Rℓ

of the form

Fℓ(x)=ϕℓ(Wℓx+bℓ),

where:

  • Wℓ∈Rnℓ×nℓ−1 is the weight matrix (with the ith row representing the weights for the inputs to the ith neuron in the layer),
  • bℓ∈Rnℓ is the bias vector (with the ith entry representing the bias on the ith neuron in the layer,
  • ϕℓ:R→R is an activation function, applied @componentwise,
  • each coordinate of Fℓ(x) is the output of a single neuron in that layer.

A layer takes an input vector, applies the same affine transformation to all neurons (via a shared weight matrix and bias vector), and then applies an @activation-function to each neuron's output.

Its output is the vector of all neuron outputs in that layer, and in this way, we can view a layer as a vector of neurons.

Referenced by (1 direct, 1 transitive)

Direct references:

Transitive (depth 1):

Finally we'll define neural network itself!

Definition: Neural Network \@{neural-network}

A neural network is a function obtained by @composing @finitely-many neurons arranged in layers:

F(x)=(ϕL∘AL)∘⋯∘(ϕ1∘A1)(x),

where each

  • ϕℓ is an @activation-function applied @componentwise,
  • and Wℓ,bℓ are learnable parameters.
Referenced by (3 direct)

Our pixels are represented by a value from 0 to 1 that represents intensity, with 0 being