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

7 篇文章 1 订阅

本文地址:http://blog.csdn.net/mounty_fsc/article/details/51090698

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

1 测试网络结构

No.Layerlayer TypeBottom BlobTop BlobTop Blob Shape
1minstDatadata
&&
label
100 1 28 28 (78400)
&&
100 (100)
2label_mnist
_1_split
Splitlabellabel_mnist_1_split_0
&&
label_mnist_1_split_1
100 (100)
&&
100 (100)
3conv1Convolutiondataconv1100 20 24 24 (1152000)
4pool1Poolingconv1pool1100 20 12 12 (288000)
5conv2Convolutionpool1conv2100 50 8 8 (320000)
6pool2Poolingconv2pool2100 50 4 4 (80000)
7ip1InnerProductpool2ip1100 500 (50000)
8relu1ReLUip1ip1(in-place)100 500 (50000)
9ip2InnerProductip1ip2100 10 (1000)
10ip2_ip2_0_splitSplitip2ip2_ip2_0_split_0
&&
ip2_ip2_0_split_1
100 10 (1000)
&&
100 10 (1000)
11accuracyAccuracyip2_ip2_0_split_0
&&
label_mnist_1_split_0
accuracy(1)
12lossSoftmaxWithLossip2_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);
    
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值