diff --git a/python/paddle/fluid/dygraph/nn.py b/python/paddle/fluid/dygraph/nn.py index a644eaf368df366f3f1c5fe74009783552683456..1af9c0ae779b473f8f95ae129d1b1692bdf53e36 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 aab315a62b752a0fcba14ccd9eddee5d06649a54..825f6d7a180919ba868cdf0fca5b0248d54d21dd 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 d497662f190061a96b869e6b8ad33225bc7fd22e..e13d3ce00b914c1cc2de7541816649fb9ce9c181 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(