From 606a99d935aac8384593b3550eceb90c44faab57 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Wed, 5 Apr 2017 15:44:02 +0800 Subject: [PATCH] Fix unittest for rnn. --- python/paddle/v2/config_base.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/paddle/v2/config_base.py b/python/paddle/v2/config_base.py index cce12c5bf..96a1c70ed 100644 --- a/python/paddle/v2/config_base.py +++ b/python/paddle/v2/config_base.py @@ -99,9 +99,9 @@ class Layer(object): # parse myself. ret_val = self.to_proto_impl(**kwargs) - if self.context_name() is not None: - assert self.context_name() not in context - # add myself to context + + if self.context_name() is not None and \ + self.context_name() not in context: context[self.context_name()] = ret_val # parse children. @@ -117,7 +117,10 @@ class Layer(object): continue layer.to_proto(context=context) - return ret_val + if self.use_context_name(): + return context[self.context_name()] + else: + return context[self.name] def to_proto_impl(self, **kwargs): raise NotImplementedError() -- GitLab