From 966a95e329ee4c5907c643cb72d341e51c10cf3a Mon Sep 17 00:00:00 2001 From: Luo Tao Date: Tue, 16 May 2017 16:40:41 +0800 Subject: [PATCH 1/2] add assert when is_seq=True, there must be bootLayer --- python/paddle/trainer_config_helpers/layers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/paddle/trainer_config_helpers/layers.py b/python/paddle/trainer_config_helpers/layers.py index 3b6f0270de166..dcf1c05bd6a29 100755 --- a/python/paddle/trainer_config_helpers/layers.py +++ b/python/paddle/trainer_config_helpers/layers.py @@ -2916,6 +2916,8 @@ def memory(name, boot_bias = ParamAttr.to_bias(boot_bias) assert boot_layer is None or isinstance(boot_layer, LayerOutput) + if is_seq == True: + assert isinstance(boot_layer, LayerOutput) if name is not None: memory_name = None From 23e00ba37990f34981c80f25f5a66c18ba0154b4 Mon Sep 17 00:00:00 2001 From: Luo Tao Date: Wed, 17 May 2017 12:55:38 +0800 Subject: [PATCH 2/2] follow comments --- python/paddle/trainer/config_parser.py | 3 +++ python/paddle/trainer_config_helpers/layers.py | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/trainer/config_parser.py b/python/paddle/trainer/config_parser.py index 57d30b088b873..9135f38719a44 100644 --- a/python/paddle/trainer/config_parser.py +++ b/python/paddle/trainer/config_parser.py @@ -2320,6 +2320,9 @@ def Memory(name, memory_name = name + "+delay1" agent_name = memory_name if is_sequence: + config_assert( + boot_layer is not None, + "there must be boot_layer in network when is_sequence = True") agent_layer = SequenceAgentLayer(agent_name, size) else: agent_layer = AgentLayer(agent_name, size) diff --git a/python/paddle/trainer_config_helpers/layers.py b/python/paddle/trainer_config_helpers/layers.py index dcf1c05bd6a29..3b6f0270de166 100755 --- a/python/paddle/trainer_config_helpers/layers.py +++ b/python/paddle/trainer_config_helpers/layers.py @@ -2916,8 +2916,6 @@ def memory(name, boot_bias = ParamAttr.to_bias(boot_bias) assert boot_layer is None or isinstance(boot_layer, LayerOutput) - if is_seq == True: - assert isinstance(boot_layer, LayerOutput) if name is not None: memory_name = None