如何在同一原型中生成数据层(HDF5)以进行培训和测试? [英] How can I generate data layer (HDF5) for training and testing in same prototxt?

查看:97
本文介绍了如何在同一原型中生成数据层(HDF5)以进行培训和测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HDF5类型的数据层.它包含预期的培训和测试阶段

I have a data layer with HDF5 type. It contains both Train and Test phase as expected

name: "LogisticRegressionNet"
layer {
  name: "data"
  type: "HDF5Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  hdf5_data_param {
    source: "examples/hdf5_classification/data/train.txt"
    batch_size: 10
  }
}
layer {
  name: "data"
  type: "HDF5Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  hdf5_data_param {
    source: "examples/hdf5_classification/data/test.txt"
    batch_size: 10
  }
}

我想使用python生成它.这是我的代码

I want to use python to generate it. This is my code

import caffe
from caffe import layers as L  # pseudo module using __getattr__ magic to generate protobuf messages
from caffe import params as P  # pseudo module using __getattr__ magic to generate protobuf messages
n = caffe.NetSpec()
n.data, n.label = L.HDF5Data(batch_size=batch_size, source='examples/hdf5_classification/data/train.txt', ntop=2, include={'phase': caffe.TRAIN})
n.data, n.label = L.HDF5Data(batch_size=batch_size, source='examples/hdf5_classification/data/test.txt',ntop=2, include={'phase': caffe.TEST})

但是,我的输出只是测试"阶段.我该如何解决?谢谢

However, my output is only Test phase. How can I fix it? Thanks

layer {
  name: "data"
  type: "HDF5Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  hdf5_data_param {
    source: "examples/hdf5_classification/data/test.txt"
    batch_size: 2
  }
}

推荐答案

这是一个未解决的问题在Caffe中(您可以在此处找到指向其他相关SO线程的链接).

This is an open issue in caffe (you can find links to other relevant SO threads there).

您可以做的是写两个prototxt,一个写给火车,一个写给测试. resolver.prototxt支持火车网络文件名和测试网络文件名的定义.

What you can do is write two prototxt one for train and one for test. solver.prototxt support definition of train net file name and test net file name.

这篇关于如何在同一原型中生成数据层(HDF5)以进行培训和测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆