caffe data层,通过Caffe中的一层获取数据的多种途径

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.

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?

解决方案

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())

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值