【问题标题】:Save the weights for a specific layer, not only visualize on Caffe保存特定层的权重,不仅在 Caffe 上可视化
【发布时间】:2019-12-22 07:51:48
【问题描述】:

我已将此网络加载到网络 net = caffe.Net('mobilenet_v2_deploy.prototxt', caffe.TEST)。然后,为了保存这一层的权重,我可以这样做net.save('mymodel.caffemodel') 但是,我怎么能保存特定层的权重 ?我知道要可视化 conv1 层的权重,我可以做 (1) net.params['conv1'][0].data 但是,这只是在命令行上输出一些文本,它不会保存类似 caffemodel 的文件。

(1) 输出诸如:(不保存文件)

array([[[[-0.1010774 ]],
        [[-0.03301976]],
        [[ 0.19851202]],
        ...,}

prototxt 文件示例

"name: "MOBILENET_V2"
#  transform_param {
#    scale: 0.017
#    mirror: false
#    crop_size: 224
#    mean_value: [103.94,116.78,123.68]
#  }
input: "data"
input_dim: 1
input_dim: 3
input_dim: 224
input_dim: 224
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 1
    kernel_size: 3
    stride: 2
    weight_filler {
      type: "msra"
    }
  }
}

【问题讨论】:

    标签: caffe


    【解决方案1】:

    您可以使用this answer 中描述的方法将权重转换为numpy,然后numpy.save() 只转换您关心的权重。

    【讨论】:

      猜你喜欢
      • 2017-07-26
      • 2017-11-29
      • 2017-11-28
      • 2017-11-10
      • 1970-01-01
      • 2018-03-18
      • 1970-01-01
      • 1970-01-01
      • 2019-04-18
      相关资源
      最近更新 更多