From 23fb630e05b5e2814da7c4fa4b75530287fe56a1 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 3 Aug 2019 13:05:39 +0200 Subject: [PATCH] Use ==/!= to compare str, bytes, and int literals Identity is not the same thing as equality in Python. $ python ``` >>> self_dtype = "float" >>> self_dtype += "16" >>> self_dtype == "float16" True >>> self_dtype is "float16" False ``` --- model/ernie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/ernie.py b/model/ernie.py index 295b21a..95822c5 100644 --- a/model/ernie.py +++ b/model/ernie.py @@ -134,7 +134,7 @@ class ErnieModel(object): emb_out = pre_process_layer( emb_out, 'nd', self._prepostprocess_dropout, name='pre_encoder') - if self._dtype is "float16": + if self._dtype == "float16": emb_out = fluid.layers.cast(x=emb_out, dtype=self._dtype) input_mask = fluid.layers.cast(x=input_mask, dtype=self._dtype) self_attn_mask = fluid.layers.matmul( -- GitLab