Skip to content

caffe-python-layers question #2

@Andybert

Description

@Andybert

I follow the style of the python_poke_layer.py file and wrote a python layer as follows:

class SampleCrossPoolingLayer(caffe.Layer):
    def parse_args(cls, argsStr):
        parser = argparse.ArgumentParser(description='SampleCrossPoolingLayer')
        parser.add_argument('--kernel_size', default=2, type=int)
        parser.add_argument('--pool', default='', type=str)
        args = parser.parse_args(argsStr.split())
        print('Using Config:')
        pprint.pprint(args)
        return args

    def setup(self, bottom, top):
        self.params_ = SampleCrossPoolingLayer.parse_args(self.param_str)

then used it in the net profile:

 layer {
  name: "mp"
  type: "Python"
  bottom: "fc1"
  bottom: "label"
  top: "mp1"
  top: "mp1_label"
  python_param {
    module: "my_cross_pooling"
    layer: "SampleCrossPoolingLayer"
    param_str: "--kernel_size=6 --pool=mean"
  }
}

I got an error:
[libprotobuf ERROR google/protobuf/text_format.cc:298] Error parsing text-format caffe.NetParameter: 133:14: Message type "caffe.PythonParameter" has no field named "param_str".

would it be possible to tell me how to solve this problem? Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions