Merge pull request #2073 from jacquesqiao/layer-attr

add attr() interface to layer
feature/design_of_v2_layer_converter
jacquesqiao 8 years ago committed by GitHub
commit b333531411

@ -16,6 +16,7 @@ import collections
import re
from paddle.trainer_config_helpers.default_decorators import wrap_name_default
import paddle.trainer_config_helpers as conf_helps
from topology import Topology
class LayerType(type):
@ -161,6 +162,10 @@ class Layer(object):
"""
return self.__context__[self.context_name()].size
def attr(self):
topo = Topology(self)
return topo.get_layer_proto(self.name)
def __convert_to_v2__(method_name,
parent_names,

@ -130,6 +130,12 @@ class Topology(object):
return [(nm, data_layers[nm].type)
for nm in self.proto().input_layer_names]
def get_layer_proto(self, name):
for layer in self.__model_config__.layers:
if layer.name == name:
return layer
return None
def __check_layer_type__(layer):
if not isinstance(layer, v2_layer.LayerV2):

Loading…
Cancel
Save