caffe之cifar10_quick.prototxt详解

cifar10_quick.prototxt就是该网络的deploy.prototxt,此处加以理解网络部署文件:

name: "CIFAR10_quick_test" #每个网络都有一个名字,子单位都是一个一个层layer
layer {
 name: "data" #每一层都有一个名字,起ID的作用
  type: "Input" #根据所属类型去创建该层,属于哪层就打开相应.cpp文件
  top: "data" #输出数据的标号
  input_param { shape: { dim: 1 dim: 3 dim: 32 dim: 32 } } #应该是创建该层所需参数
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data" #输入是上面输出的“data”
  top: "conv1"
#filters的学习率,还可以加上衰减参数  decay_mult: XX
param {
    lr_mult: 1
  }
#biases的学习率,还可以加上衰减参数  decay_mult: XX
param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 32
    pad: 2
    kernel_size: 5
    stride: 1
  }
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "pool1"
  top: "pool1"
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 32
    pad: 2
    kernel_size: 5
    stride: 1
  }
}
layer {
  name: "relu2"
  type: "ReLU"
  bottom: "conv2"
  top: "conv2"
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: AVE
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "conv3"
  type: "Convolution"
  bottom: "pool2"
  top: "conv3"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 64
    pad: 2
    kernel_size: 5
    stride: 1
  }
}
layer {
  name: "relu3"
  type: "ReLU"
  bottom: "conv3"
  top: "conv3"
}
#一般 ReLU跟在谁的后面就是看图说话的,看你设计,有的在conv后面,有的在pooling后面
layer {
  name: "pool3"
  type: "Pooling"
  bottom: "conv3"
  top: "pool3"
  pooling_param {
    pool: AVE
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "ip1"
  type: "InnerProduct"#是全连接层
  bottom: "pool3"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 64
  }
}
#一个全连接层,一个softmax层,后面的一个 InnerProduct与 Softmax层共同组成整体的softmax预测类别的层
layer {
  name: "ip2"
  type: "InnerProduct"
  bottom: "ip1"
  top: "ip2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 10
  }
}
layer {
  name: "prob"
  type: "Softmax"
  bottom: "ip2"
  top: "prob"
}

注意:由于train或者test的网络要计算损失函数或者准确率,所以某层的输出与输入可以有多个:

name: "mnist"
  type: "Data"
  top: "data"
  top: "label" 或者
name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"

  bottom: "label"

你可能感兴趣的:(caffe之cifar10_quick.prototxt详解)