Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neural network 如何在映像目录外为暹罗网络创建CaffeDB训练数据_Neural Network_Deep Learning_Caffe_Conv Neural Network_Training Data - Fatal编程技术网

Neural network 如何在映像目录外为暹罗网络创建CaffeDB训练数据

Neural network 如何在映像目录外为暹罗网络创建CaffeDB训练数据,neural-network,deep-learning,caffe,conv-neural-network,training-data,Neural Network,Deep Learning,Caffe,Conv Neural Network,Training Data,我需要一些帮助,以创建一个CaffeDB为暹罗有线电视新闻网出一个普通目录与图像和标签文本文件。最好是用python的方式来实现。 问题不在于遍历目录并制作成对的图像。我的问题更多的是用这些对做一个CaffeDB。 到目前为止,我只使用图像目录创建CaffeDB。 谢谢你的帮助 为什么不使用好的旧convert\u imagest创建两个数据集呢 layer { name: "data_a" top: "data_a" top: "label_a" type: "Data"

我需要一些帮助,以创建一个CaffeDB为暹罗有线电视新闻网出一个普通目录与图像和标签文本文件。最好是用python的方式来实现。
问题不在于遍历目录并制作成对的图像。我的问题更多的是用这些对做一个CaffeDB。
到目前为止,我只使用图像目录创建CaffeDB。

谢谢你的帮助

为什么不使用好的旧
convert\u imagest
创建两个数据集呢

layer {
  name: "data_a"
  top: "data_a"
  top: "label_a"
  type: "Data"
  data_param { source: "/path/to/first/data_lmdb" }
  ...
}
layer {
  name: "data_b"
  top: "data_b"
  top: "label_b"
  type: "Data"
  data_param { source: "/path/to/second/data_lmdb" }
  ...
}
至于损失,由于每个示例都有一个类标签,您需要将
标签a
标签b
转换为
相同的标签
。我建议您使用python层“即时”完成此操作。在
prototxt
中添加对python层的调用:

layer {
  name: "a_b_to_same_not_same_label"
  type: "Python"
  bottom: "label_a"
  bottom: "label_b"
  top: "same_not_same_label"
  python_param { 
    # the module name -- usually the filename -- that needs to be in $PYTHONPATH
    module: "siamese"
    # the layer name -- the class name in the module
    layer: "SiameseLabels"
  }
  propagate_down: false
}
创建
siamese.py
(确保它位于
$PYTHONPATH
中)。在
siamese.py
中,您应该拥有图层类:

import sys, os
sys.path.insert(0,os.environ['CAFFE_ROOT'] + '/python')
import caffe
class SiameseLabels(caffe.Layer):
  def setup(self, bottom, top):
    if len(bottom) != 2:
       raise Exception('must have exactly two inputs')
    if len(top) != 1:
       raise Exception('must have exactly one output')
  def reshape(self,bottom,top):
    top[0].reshape( *bottom[0].shape )
  def forward(self,bottom,top):
    top[0].data[...] = (bottom[0].data == bottom[1].data).astype('f4')
  def backward(self,top,propagate_down,bottom):
      # no back prop
      pass
确保以不同的方式在两个集合中洗牌示例,以便获得非平凡的对。此外,如果您使用不同数量的示例构建第一个和第二个数据集,那么您将在每个历元看到不同的对;)



确保构建网络以共享复制层的权重,有关详细信息,请参阅。

为什么不使用良好的旧
转换\u imagest创建两个数据集

layer {
  name: "data_a"
  top: "data_a"
  top: "label_a"
  type: "Data"
  data_param { source: "/path/to/first/data_lmdb" }
  ...
}
layer {
  name: "data_b"
  top: "data_b"
  top: "label_b"
  type: "Data"
  data_param { source: "/path/to/second/data_lmdb" }
  ...
}
至于损失,由于每个示例都有一个类标签,您需要将
标签a
标签b
转换为
相同的标签
。我建议您使用python层“即时”完成此操作。在
prototxt
中添加对python层的调用:

layer {
  name: "a_b_to_same_not_same_label"
  type: "Python"
  bottom: "label_a"
  bottom: "label_b"
  top: "same_not_same_label"
  python_param { 
    # the module name -- usually the filename -- that needs to be in $PYTHONPATH
    module: "siamese"
    # the layer name -- the class name in the module
    layer: "SiameseLabels"
  }
  propagate_down: false
}
创建
siamese.py
(确保它位于
$PYTHONPATH
中)。在
siamese.py
中,您应该拥有图层类:

import sys, os
sys.path.insert(0,os.environ['CAFFE_ROOT'] + '/python')
import caffe
class SiameseLabels(caffe.Layer):
  def setup(self, bottom, top):
    if len(bottom) != 2:
       raise Exception('must have exactly two inputs')
    if len(top) != 1:
       raise Exception('must have exactly one output')
  def reshape(self,bottom,top):
    top[0].reshape( *bottom[0].shape )
  def forward(self,bottom,top):
    top[0].data[...] = (bottom[0].data == bottom[1].data).astype('f4')
  def backward(self,top,propagate_down,bottom):
      # no back prop
      pass
确保以不同的方式在两个集合中洗牌示例,以便获得非平凡的对。此外,如果您使用不同数量的示例构建第一个和第二个数据集,那么您将在每个历元看到不同的对;)



请确保构建网络以共享复制层的权重,有关详细信息,请参阅。

您将使用哪一损失层?我还不知道。对于我的用例,每个类(4+垃圾类)都有一些图像(100k),我希望网络能够更好地区分不同的类。有了“正常”的线性CNN,网络就有很多错误,我想尝试一个暹罗CNN,让网络更好地了解差异。如果您对好的损耗层有一些建议,请告诉我。对比损耗层似乎适合此用例。thx用于此,所以caffeDB的问题仍然存在…您将使用什么损耗层?我还不知道。对于我的用例,每个类(4+垃圾类)都有一些图像(100k),我希望网络能够更好地区分不同的类。有了“正常”的线性CNN,网络就有很多错误,我想尝试一个暹罗CNN,让网络更好地了解差异。如果您对良好的丢失层有一些建议,请告诉我。对比丢失层似乎适合此用例。thx用于此,所以caffeDB的问题仍然存在…我在caffe/python和python2.7安装目录中都没有找到siamese.py文件。我正在开发Ubuntu 15.04,并于2015年10月获得了caffe主分支。只有mnist暹罗示例,我已经在教程中使用共享参数设计了网络,只是数据输入的开头我不清楚。到目前为止,我还没有使用python层。我只是为给定的solver.prototxt定义网络并使用train命令运行caffe。比如:caffe train-solver.prototxt-gpu all。我的数据层指的是带有*.mdb和平均二进制proto的目录file@Feuerteufel您需要创建一个
siamese.py
文件,并确保它位于
$PYTHONPATH
中。此文件应包含问题中的代码(以及导入caffe所需的适当的
导入
s)。如果您在中启用了python层,那么caffe将为您运行python代码,作为其
caffe系列的一部分。好的,python层未启用,因此我现在正在重建它。为siamese.py导入的正确行是“import sys”、“sys.path.insert(0,'path/to/caffe/python')”和“import caffe”或其他什么?在损耗层中,相同的\u不\u相同的\u标签用作第三个输入?@Feuerteufel相同的\u不\u相同的\u标签用作对比损耗的标签。如果我有N个标签。我怎样才能保证,在对比损失层之前大小为N的特征向量代表每个类别的某种概率?或者说这是暹罗网络设计自动生成的?我在caffe/python和python2.7 install dir中都没有找到siamese.py文件。我正在开发Ubuntu 15.04,并于2015年10月获得了caffe主分支。只有mnist暹罗示例,我已经在教程中使用共享参数设计了网络,只是数据输入的开头我不清楚。到目前为止,我还没有使用python层。我只是为给定的solver.prototxt定义网络并使用train命令运行caffe。比如:caffe train-solver.prototxt-gpu all。我的数据层指的是带有*.mdb和平均二进制proto的目录file@Feuerteufel您需要创建一个
siamese.py
文件,并确保它位于
$PYTHONPATH
中。此文件应包含问题中的代码(以及导入caffe所需的适当的
导入
s)。如果您在中启用了python层,那么caffe将为您运行python代码,作为其
caffe系列的一部分。好的,python层未启用,因此我现在正在重建它。为siamese.py导入的正确行是“import sys”、“sys.path.insert(0,'path/to/caffe/python')”