数据层:
layer {
name: "data" #定义名字,名字可以随意取
type: "ImageData" #图像数据层
top: "data" #一般用bottom表示输入,top表示输出,多个top有多个输出
top: "label"
include {
phase: TRAIN #训练网络分为训练阶段和自测试阶段,如果没写 include则表示该层即在测试中,又在训练中
}
transform_param {
mirror: false #false表示不开启镜像操作 True表示开启
crop_size: 227 #再随机裁剪 227*227 增加数据
#scase 0.0039215 归一化,将原来【0,255】的值压缩到0--1之间
mean_file: "data/ilsvrc12/imagenet_mean.binaryproto" #用一个配置文件进行均值计算 -mean操作 RGB三通道 R-mR
}
image_data_param {
source: "examples/_temp/file_list.txt" #数据库来源
batch_size: 50 #每次批处理的个数 一般 2的n次幂
#backend: LMDB #数据源的名称
new_height: 256 #resize 图片的大小
new_width: 256
}
}
卷积层
layer {
name: "conv1"
type: "Convolution" #卷积层
bottom: "data"
top: "conv1"
convolution_param {
num_output: 96 #卷积核(filter)的个数
#lr_mult: 1 #学习率的系数,最终的学习率是这个数乘以solver.prototxt配置文件中的base_lr。如果有两个lr_mult,则第一个表示权值的学习率,第二个是偏置项的学习率。
kernel_size: 11 #卷积核的大小
stride: 4 #卷积核的步长
#pad:0 #扩充边缘,默认为0,不扩充,是边缘信息多进行卷积操作
}
weight_filler{
type: "xavier" #权值初始化。默认为“constant”,值为0,很多时候我们用“xavier”,也可用“gaussion”
}
bias_filter{
type: "constant" #偏置项的初始化,一般设置为“constant”,值全为0
}
}
激活函数,一般接在卷积层后面
layer {
name: "relu1"
type: "ReLU" #激活函数 Sigmoid ReLU--->标准的ReLU函数为max(x,0),当x>0时,输出x;当x<=0时,输出0
bottom: "conv1"
top: "conv1"
}
池化层
layer {
name: "pool1"
type: "Pooling" #池化层
bottom: "conv1"
top: "pool1"
pooling_param {
pool: MAX #池化方法,默认为MAX,目前的方法有,MAX,AVE
kernel_size: 3
stride: 2
}
}
全连接层
layer {
name: "fc6"
type: "InnerProduct" #全连接层,输出的是一个简单向量 参数跟卷积层一样
bottom: "pool5"
top: "fc6"
inner_product_param {
num_output: 4096 #
}
}
防止过拟合的层
layer {
name: "drop6"
type: "Dropout" #防止过拟合的层
bottom: "fc6"
top: "fc6"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "prob"
type: "Softmax" #输出准确值
bottom: "fc8"
top: "prob"
}
layer {
name: "accuracy"
type: "Accuracy" #测试输入准确率
bottom: "prob"
bottom: "label"
top: "accuracy"
}
layer {
name: "loss"
type: "SoftmaxWithLoss" #计算loss
bottom: "fc8"
bottom: "label"
top: "loss"
}
#在不改变数据的情况下,改变输入的维度
#layer{
# name : "reshape"
# type : "Reshape"
# bottom: "input"
# top : "output"
# reshape_param{
# shape{
# dim: 0 #copy the dimension from below
# dim: 2
# dim: 3
# dim: -1 #infer it from the other dimensions
# }
# }
#}
#有一个可选的参数组shape,用于指定blob数据的各维的值(blob是一个四维的数据:n*c*w*h)
#dim:0 表示维度不变,即输入和输出是相同的维度
#dim:2 或3 将原来的维度变为 2 或 3
#dim:-1 表示由系统自动计算维度,数据的总量不变系统会根据blob数据的其它三维来自动计算当前维度的维度值
#假设原数据为:32*3*28*28,表示32张3通道的28*28的彩色图
# shape{
# dim: 0 #copy the dimension from below
# dim: 0
# dim: 14
# dim: -1 #infer it from the other dimensions
# }
#输出数据为 32*3*14*56
以上内容,是观看唐宇迪课程《深度学习Caffe框架入门》所作笔记。