Russian Dolls : Entire Network Embedding ?J

41 views
Skip to first unread message

Etienne Perot

unread,
Oct 27, 2015, 6:21:19 AM10/27/15
to Caffe Users
Hello! 

I would like to know if there is a way to embedd an entire network defined into a prototxt+caffemodel into a layer? 

My first idea is to define a python Layer like this :

layer {
  type: 'Python'
  name: 'AlexNet'
  top: 'AlexNet'
bottom: "Images"
  python_param {
    # the module name -- usually the filename -- that needs to be in $PYTHONPATH
    module: 'net_wrapper'
    # the layer name -- the class name in the module
    layer: 'AlexNetWrap'
  }
}

& define in my caffe "custom" Python directory (registered in Python Path)

class AlexNetWrap(caffe.Layer):

  def setUp(self):

    net_file = './alexnet.prototxt'

    weights = '/home/valeodar/caffe_0/models/bvlc_reference_caffenet/params.caffemodel'

    self.net = caffe.Net(net_file, weights, caffe.TRAIN)

    print 'wtf'


  def reshape(self, bottom, top):

    # check input dimensions match

    if bottom[0].count != bottom[1].count:

    raise Exception("Inputs must have the same dimension.")

    # difference is shape of inputs

    self.diff = np.zeros_like(bottom[0].data, dtype=np.float32)

    # loss output is scalar

    top[0].reshape(1)


  def forward(self, bottom, top):

    self.forward(bottom,top)


  def backward(self, top, bottom):

    self.backward(bottom,top)



But calling the first prototxt raises following Exception :

RuntimeError: maximum recursion depth exceeded while calling a Python object

Is there something I am missing ?

Bjørn Rustad

unread,
Oct 28, 2015, 10:35:22 AM10/28/15
to caffe...@googlegroups.com
On Tue, Oct 27, 2015, at 11:21, Etienne Perot wrote:
> class AlexNetWrap(caffe.Layer):
>
> def setUp(self):

Try calling this setup with a lower-case u.

https://groups.google.com/forum/#!topic/caffe-users/4tQKQuFS6Iw

--
Bjørn Rustad
bj...@rustad.me
Reply all
Reply to author
Forward
0 new messages