From f16195aa8b1569e0260c48d4159b7d2ce0ea2fab Mon Sep 17 00:00:00 2001 From: Jonathan L Long Date: Thu, 23 Jul 2015 20:32:04 -0700 Subject: [PATCH] [pycaffe] add Top._to_proto convenience function This makes it possible to serialize Functions or Tops with a uniform interface. --- python/caffe/net_spec.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/caffe/net_spec.py b/python/caffe/net_spec.py index 37e333d..5fb26ed 100644 --- a/python/caffe/net_spec.py +++ b/python/caffe/net_spec.py @@ -87,6 +87,9 @@ class Top(object): return to_proto(self) + def _to_proto(self, layers, names, autonames): + return self.fn._to_proto(layers, names, autonames) + class Function(object): """A Function specifies a layer, its parameters, and its inputs (which @@ -116,7 +119,7 @@ class Function(object): return bottom_names = [] for inp in self.inputs: - inp.fn._to_proto(layers, names, autonames) + inp._to_proto(layers, names, autonames) bottom_names.append(layers[inp.fn].top[inp.n]) layer = caffe_pb2.LayerParameter() layer.type = self.type_name @@ -163,7 +166,7 @@ class NetSpec(object): autonames = Counter() layers = OrderedDict() for name, top in six.iteritems(self.tops): - top.fn._to_proto(layers, names, autonames) + top._to_proto(layers, names, autonames) net = caffe_pb2.NetParameter() net.layer.extend(layers.values()) return net -- 2.7.4