From 9220005c323299623dff4bcca29a57ea44be4aa5 Mon Sep 17 00:00:00 2001 From: zhongpu <2013000149@qq.com> Date: Tue, 28 Apr 2020 10:53:35 +0800 Subject: [PATCH] fix if logic in dygraph, test=develop (#24209) --- 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 a644eaf368d..1af9c0ae779 100644 --- a/python/paddle/fluid/dygraph/nn.py +++ b/python/paddle/fluid/dygraph/nn.py @@ -961,7 +961,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 aab315a62b7..825f6d7a180 100644 --- a/python/paddle/fluid/layers/loss.py +++ b/python/paddle/fluid/layers/loss.py @@ -473,7 +473,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 d497662f190..e13d3ce00b9 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -1022,7 +1022,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