美文网首页Caffe
(Caffe,LeNet)初始化测试网络(四)

(Caffe,LeNet)初始化测试网络(四)

作者: 沤江一流 | 来源:发表于2016-04-08 00:42 被阅读252次

    本文从CSDN上转移过来:
    http://blog.csdn.net/mounty_fsc/article/details/51090698

    在 (Caffe,Lenet5)初始化训练网络(三)中介绍了训练网络的初始化,本文介绍测试网络的初始化。

    1 测试网络结构

    No. Layer layer Type Bottom Blob Top Blob Top Blob Shape
    1 minst Data data&&label 100 1 28 28 (78400)&&100 (100)
    2 label_mnist_1_split Split label label_mnist_1_split_0&&label_mnist_1_split_1 100 (100)&&100 (100)
    3 conv1 Convolution data conv1 100 20 24 24 (1152000)
    4 pool1 Pooling conv1 pool1 100 20 12 12 (288000)
    5 conv2 Convolution pool1 conv2 100 50 8 8 (320000)
    6 pool2 Pooling conv2 pool2 100 50 4 4 (80000)
    7 ip1 InnerProduct pool2 ip1 100 500 (50000)
    8 relu1 ReLU ip1 ip1(in-place) 100 500 (50000)
    9 ip2 InnerProduct ip1 ip2 100 10 (1000)
    10 ip2_ip2_0_split Split ip2 ip2_ip2_0_split_0&&ip2_ip2_0_split_1 100 10 (1000)&&100 10 (1000)
    11 accuracy Accuracy ip2_ip2_0_split_0&&label_mnist_1_split_0 accuracy (1)
    12 loss SoftmaxWithLoss ip2_ip2_0_split_1&&label_mnist_1_split_1 loss (1)

    注:Top Blob Shape格式为:BatchSize,ChannelSize,Height,Width(Total Count)

    2 与训练网络对比

    1. 训练网络9层,测试网络12层
    2. 训练网络没有的是:多了label_mnist_1_split、layer ip2_ip2_0_split、accuracy,类型为Split LayerAccuracy Layer

    3 Split Layer

    其功能主要是复制blob,将一个bottom blob复制成多个top blob

    4 Accuracy Layer

    Accuracy完成的任务是统计预测正确样本的个数信息。如总样本N个,正确分类n个,正确率为n/N。

    主要变量:

    • label_axis_为标签对应的轴(对应的blob中的那个维度)
    • outer_num_总的来说是样本数量,详细解释见后面
    • inner_num_同上,总的来说是样本数量,详细解释见后面
    • top_k为取前k个最高评分(的预测标签)
    message AccuracyParameter {
    ...
      // The "label" axis of the prediction blob, whose argmax corresponds to the
      // predicted label -- may be negative to index from the end (e.g., -1 for the
      // last axis).  For example, if axis == 1 and the predictions are
      // (N x C x H x W), the label blob is expected to contain N*H*W ground truth
      // labels with integer values in {0, 1, ..., C-1}.
      optional int32 axis = 2 [default = 1];
    }
    

    定义中关于axis的说明:

    1. axis指出在预测blob中,哪一维是label轴,如(N x C x H x W)的blob,axis=0,则N为label对应的维度。axis=1,则C为label对应的维度,而剩下的N为outer样本数量, H x W为inner样本数量。
    2. 由代码可知,当axis=kouter_num_=blob.shape[0,..,k),inner_num_=blob.shape[k+1,..,shape.size)
    3. 一般的,label blob的维度为(N x C),N为样本数量,C为标签数量(即类别个数)。axis=1,outer_num_=N,inner_num_=shape[2,2)=1(即没有inner)
      outer_num_ = bottom[0]->count(0, label_axis_);
      inner_num_ = bottom[0]->count(label_axis_ + 1);
      
    

    相关文章

      网友评论

        本文标题:(Caffe,LeNet)初始化测试网络(四)

        本文链接:https://www.haomeiwen.com/subject/vxlvlttx.html