CNN(Convolutional Neural Network)
Import a question:classification
given a feature representing for images, how do we learn a model for distinguishing features from different classes?
The machine learning framework
1:prediction function to get desired output:
f(🍎)=apple
f(🍅)=tomato
f(🐮)=cow
2:The framework
here, there are two activities:
- Training:knowing training set {(x1,y1)……(xn,yn)} estimate the prediction function f
- Testing:knowing f,to test x and output value y=f(x)
Neural Networks(Linear)
- Perceptron(感知机)
- Linear classifier-vector of weights w and a ‘bias b
An example of binary classifying an image
- Each pixel of the image would be an input, so, for a 28x28 image, we vectorize(矢量化),x=1x784
- w is a vector of weights for each pixel: 784x1
- b is a scalar(标量) bias per perceptron
- result=xw+b ->(1x784)(784x1)+b->(1x1)+b
[Notice: the result of multiplying xw is a scalar(dot product)]
Multuclass(add more perceptrons)
- x same as above example ->x=1x784
- W is a matrix of weights for each pixel/each perceptron
w=784x10(assume 10-class classification) - b is a bias per perceptron(vector of biases)->b=1x10
- result=xW+b=(1x784)x(784x10)+b=(1x10)+(1x10)=output vector
Bias convenience
- create a ‘fake’ feature with value 1 to represent the bias
- Add an extra weight that can vary
Then: the composition :
Outputs from one perceptron are fed into inputs of another perceptron
It’s all just matrix multiplication!