提交 b3335314 编写于 作者: J jacquesqiao 提交者: GitHub

Merge pull request #2073 from jacquesqiao/layer-attr

add attr() interface to layer
......@@ -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):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册