Saeed Saeed -4 years ago 198
Python Question

Two top blobs in train.prototxt when using caffe.NetSpec() in Python

I am using caffe.NetSpec in python to define and export in architecture using the following code:

conv1_1 = L.Convolution(data,top='conv1_1',name='conv1_1',
convolution_param=
{'kernel_size':3,'num_output':64,'pad':1},
param=[{'lr_mult':1, 'decay_mult':1},
{'lr_mult':2,'decay_mult':0}])


But, when generating the train.protxt, two Top blobs appear in the layer as follow:

layer {
name: "conv1_1"
type: "Convolution"
bottom: "Data1"
top: "Convolution1"
top: "conv1_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
pad: 1
kernel_size: 3
}
}


What's going wrong here?
Thanks

Answer Source

How about using a NetSpec() object?

import caffe

ns = caffe.NetSpec() # use this object to store the layers
ns.data, ns.label = L.Data(name='data',  ntop=2, 
                           data_param={'source':'', 'batch_size': 32})
ns.conv1_1 = L.Convolution(ns.data, name='conv1_1',
                    convolution_param=
                    {'kernel_size':3,'num_output':64,'pad':1},
                    param=[{'lr_mult':1, 'decay_mult':1},
                           {'lr_mult':2,'decay_mult':0}])
print str(ns.to_proto()) # print the net stored in ns object
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download