本文介绍了如何使用python生成连接层prototxt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个原型,如下:

layer {
  name: "data"
  type: "HDF5Data"
  top: "data1"
  top: "data2"
  top: "label"
  include {
    phase: TRAIN 
  }
  hdf5_data_param {
    source: "./source_list.txt"
    batch_size: 2
    shuffle: true 
  }
}
layer {
  name: "concat"
  type: "Concat" 
  bottom: "data1"
  bottom: "data2"
  top: "data"
  concat_param {
    concat_dim:1
  }
}

我想在python中使用caffe NetSpec生成上述prototxt.但是,这是错误的.这是我的代码.请帮我修复它.谢谢

I want to generate above prototxt using caffe NetSpec in python. However, It was wrong. This is my code. Please help me to fix it. Thanks

from caffe import layers as L
...
n = caffe.NetSpec()
n.data, n.label = L.HDF5Data(top=["data1", "data2"], batch_size=2,
                             source="./source_list.txt", ntop=2,shuffle= True,
                             include={'phase': caffe.TRAIN})
n.concat = L.Concat(n.data["data1"], n.data["data2"])

推荐答案

您需要具有两个data输出

n.data1, n.data2, n.label = L.HDF5Data(ntop=3, name="data",
                                       hdf5_data_param={'source': "./source_list.txt", 
                                                         'shuffle': True,
                                                         'batch_size': 2}
                                       include={'phase': caffe.TRAIN})
n.data = L.Concat(n.data1, n.data2, name="concat", concat_param={'concat_dim':1})

这篇关于如何使用python生成连接层prototxt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 06:59