【Caffe】详解lenet_train_test.prototxt的网络结构

 


#网络
name: "LeNet"
#指定训练train的数据集和参数
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "examples/mnist/mnist_train_lmdb"
    batch_size: 64
    backend: LMDB
  }
}
#指定测试test的数据集和参数
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "examples/mnist/mnist_test_lmdb"
    batch_size: 100
    backend: LMDB
  }
}
#所有的层都具有的参数,如name, type, bottom, top和transform_param
#卷积层conv1
#其他:
#pad: 扩充边缘,默认为0,不扩充。 
#bias_term: 是否开启偏置项,默认为true, 开启
#group: 分组,默认为1组。如果大于1,我们限制卷积的连接操作在一个子集内。
#       如果我们根据图像的通道来分组,那么第i个输出分组只能与第i个输入分组进行连接。

#输入:n*c0*w0*h0
#输出:n*c1*w1*h1
#其中,c1就是参数中的num_output,生成的特征图个数
# w1=(w0+2*pad-kernel_size)/stride+1;
# h1=(h0+2*pad-kernel_size)/stride+1;
#如果设置stride为1,前后两次卷积部分存在重叠。如果设置pad=(kernel_size-1)/2,则运算后,宽度和高度不变。
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1      #lr_mult:学习率系数;第一个表示权值的学习率
  }
  param {
    lr_mult: 2      #第二个表示偏置项的学习率。一般偏置项的学习率是权值学习率的两倍
  }
  convolution_param {
    num_output: 20    #卷积核(filter)的个数
    kernel_size: 5    #卷积核的大小;如w,h不相等,需kernel_h,kernel_w
    stride: 1         #卷积核的步长
    weight_filler {   #权值初始化
      type: "xavier"    #"xavier"算法来进行初始化
    }
    bias_filler {     #偏置项初始化
      type: "constant"  #默认为“constant",值全为0
    }
  }
}
#池化pool1
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX         #池化方法,默认为MAX。目前可用的方法有MAX, AVE, 或STOCHASTIC
    kernel_size: 2    #池化的核大小
    stride: 2         #池化的步长,默认为1。一般我们设置为2,即不重叠。
  }
}
#卷积conv2
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 50
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
#池化pool2
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
#内积层InnerProduct,实际上就是全连接层
layer {
  name: "ip1"
  type: "InnerProduct"
  bottom: "pool2"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 500       #卷积核(filter)的个数
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}

#激活函数层,ReLU
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "ip1"
  top: "ip1"
}
layer {
  name: "ip2"
  type: "InnerProduct"
  bottom: "ip1"
  top: "ip2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 10
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}

#准确率Accuracy
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
#输出层,损失函数
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "label"
  top: "loss"
}

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值