From 61d19a8e1cf760cf805b06c6d35b85e2dd57adae Mon Sep 17 00:00:00 2001 From: zhongpu <2013000149@qq.com> Date: Tue, 28 Apr 2020 13:43:36 +0800 Subject: [PATCH] fix if logic in dygraph, test=develop (#24208) --- python/paddle/fluid/dygraph/nn.py | 2 +- python/paddle/fluid/layers/loss.py | 2 +- python/paddle/fluid/layers/nn.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/dygraph/nn.py b/python/paddle/fluid/dygraph/nn.py index e9139156a14..b06fddf59fb 100644 --- a/python/paddle/fluid/dygraph/nn.py +++ b/python/paddle/fluid/dygraph/nn.py @@ -958,7 +958,7 @@ class Linear(layers.Layer): tmp = self._helper.create_variable_for_type_inference(self._dtype) self._helper.append_op( type="matmul", inputs=inputs, outputs={"Out": tmp}, attrs=attrs) - if self.bias: + if self.bias is not None: pre_activation = self._helper.create_variable_for_type_inference( dtype=self._dtype) self._helper.append_op( diff --git a/python/paddle/fluid/layers/loss.py b/python/paddle/fluid/layers/loss.py index 18790317e53..04a803dfa54 100644 --- a/python/paddle/fluid/layers/loss.py +++ b/python/paddle/fluid/layers/loss.py @@ -479,7 +479,7 @@ def edit_distance(input, label = erased_label this_inputs = {"Hyps": [input], "Refs": [label]} - if input_length and label_length: + if input_length is not None and label_length is not None: this_inputs['HypsLength'] = [input_length] this_inputs['RefsLength'] = [label_length] diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index de3a9ed39c0..7eaa9c0dcea 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -1137,7 +1137,7 @@ def chunk_eval(input, this_input = {"Inference": [input], "Label": [label]} - if seq_length: + if seq_length is not None: this_input["SeqLength"] = [seq_length] helper.append_op( -- GitLab