2

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 appears 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

2
  • @Shai: But I want the name of the top to be 'conv1_1'. Commented Feb 28, 2017 at 6:13
  • @Shai: I'm just stacking a bunch of layers and then feed the last layer to the 'to_proto' function. It's a very deep network. You need all the code? Note that the same behavior happens for all layers. Commented Feb 28, 2017 at 6:23

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

In this way, can we use variables inside the layer 'top's? For example, ns.conv1_1, ns.conv1_2 etc. We don't wanna write it so many times, right?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.