通过Caffe中的一层获取数据的多种途径 [英] Multiple pathways for data through a layer in Caffe

查看:325
本文介绍了通过Caffe中的一层获取数据的多种途径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Caffe中构建一个网络,在该网络中,传入的数据首先被拆分,分别经过相同的一组层,最后使用elthwise层进行重组.此后,所有零件都将作为单个斑点移动.

I would like to construct a network in Caffe in which the incoming data is split up initially, passes separately through the same set of layers, and is finally recombined using an eltwise layer. After this, all the parts will move as a single blob.

除了学习的参数外,数据并行移动的网络部分的层配置将相同.

The layer configuration of the part of the network for which the data moves parallely will be identical, except for the learned parameters.

有没有一种方法可以在Caffe中定义此网络,而无需重新定义数据不同部分多次通过的层?换句话说,是否可以一次定义一个层并具有多个输入和输出路径,例如具有多个顶部和底部参数以及它们之间的映射?

Is there a way to define this network in Caffe without redefining the layers through which the different parts of the data go through multiple times? In other words, is it possible to define a layer once and have multiple pathways for input and output, something like having multiple top and bottom parameters with a mapping between them?

推荐答案

我不认为原始caffe的prototxt格式可以满足您的需求.但是您可以使用caffe.NetSpec() python接口来获取此信息.也就是说,使用python接口构建网络并写入prototxt文件.

I don't think raw caffe's prototxt format allows for what you are after. But you can get this using caffe.NetSpec() python interface. That is, using python interface to construct the net and write the prototxt file.

import caffe
from caffe import layers as L
ns = caffe.NetSpec()
ns.data, ns.label = L.Data(ntop=2, name='data', data_param={'source':'/path/to', 'batch_size': 32})
tops = []
for i in xrange(3):
    nm = 'path{}'.format(i)
    top = L.Convolution(ns.data, name=nm, convolution_params={'num_output':32})
    ns.__setattr__(nm, top)
    tops.append(top)
# concat
ns.concat = L.Concat(*tops, name='concat', concat_param={'axis':1})
print '{}'.format(ns.toProto())

这篇关于通过Caffe中的一层获取数据的多种途径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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