CNN基础(1)

来源:互联网 发布:如何在知乎发表文章 编辑:程序博客网 时间:2024/06/08 17:39

classification = score function + loss function +optimization

score function

  • linear
  • nonlinear

这里写图片描述
An example of mapping an image to class scores. For the sake of visualization, we assume the image only has 4 pixels (4 monochrome pixels, we are not considering color channels in this example for brevity), and that we have 3 classes (red (cat), green (dog), blue (ship) class). (Clarification: in particular, the colors here simply indicate 3 classes and are not related to the RGB channels.) We stretch the image pixels into a column and perform matrix multiplication to get the scores for each class. Note that this particular set of weights W is not good at all: the weights assign our cat image a very low cat score. In particular, this set of weights seems convinced that it’s looking at a dog.


loss function (cost function, objective)

  • Multicass Support Vector Machine(SVM) loss

    Li=jyimax(0,sjsyi+Δ)    (hinge loss)

  • squared hinge loss

  • cross-entropy loss

    Li=logefyijefjor equivalentlyLi=fyi+logjefj

    where
    fj(z)=ezjkezk

    is called softmax function


the loss function quantifies our unhappiness with predictions on the training set

这里写图片描述

The Multiclass Support Vector Machine “wants” the score of the correct class to be higher than all other scores by at least a margin of delta. If any class has a score inside the red region (or higher), then there will be accumulated loss. Otherwise the loss will be zero. Our objective will be to find the weights that will simultaneously satisfy this constraint for all examples in the training data and give a total loss that is as low as possible.


  • Regularization
    1. L1 Regularization
      R(W)=|W|

    2. L2
      R(W)=klW2k,l

    3. Drop out 这里写图片描述

the full loss becomes:
L=1NiLidata loss+λR(W)regularization loss

optimization

  • Gradient Descent

    • Stochastic Gradient Descent (SGD or on-line gradient descent)

    • Mini-batch Gradient Descent

  • backpropagation


这里写图片描述
An example circuit demonstrating the intuition behind the operations that backpropagation performs during the backward pass in order to compute the gradients on the inputs. Sum operation distributes gradients equally to all its inputs. Max operation routes the gradient to the higher input. Multiply gate takes the input activations, swaps them and multiplies by its gradient.