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,24Z10

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:RnR,N(x)=ϕ(wx+b),

where

  • n is the number of inputs to the neuron
  • wRn is a vector of weights,
  • bR is a bias value, and
  • ϕ:RR is an activation function.
Referenced by (1 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 n1 inputs and n neurons defines a function

F:R1R

of the form

F(x)=ϕ(Wx+b),

where:

  • WRn×n1 is the weight matrix (with the ith row representing the weights for the inputs to the ith neuron in the layer),
  • bRn is the bias vector (with the ith entry representing the bias on the ith neuron in the layer,
  • ϕ:RR 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.

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)=(ϕLAL)(ϕ1A1)(x),

where each

  • A(x)=Wx+b is an @affine-transformation,
  • ϕ 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