提交 3aeb517a 编写于 作者: C cclauss

Fixes for Python 3

上级 b255e121
...@@ -137,7 +137,7 @@ def parse(init_checkpoint): ...@@ -137,7 +137,7 @@ def parse(init_checkpoint):
else: else:
print("ignored param: %s" % var_name) print("ignored param: %s" % var_name)
if fluid_param_name is not '': if fluid_param_name != '':
tf_fluid_param_name_map[var_name] = fluid_param_name tf_fluid_param_name_map[var_name] = fluid_param_name
tf_param_name_shape_map[var_name] = var_shape tf_param_name_shape_map[var_name] = var_shape
fluid_param_name = '' fluid_param_name = ''
......
...@@ -109,7 +109,7 @@ class BertModel(object): ...@@ -109,7 +109,7 @@ class BertModel(object):
emb_out = pre_process_layer( emb_out = pre_process_layer(
emb_out, 'nd', self._prepostprocess_dropout, name='pre_encoder') emb_out, 'nd', self._prepostprocess_dropout, name='pre_encoder')
if self._dtype is "float16": if self._dtype == "float16":
self_attn_mask = fluid.layers.cast( self_attn_mask = fluid.layers.cast(
x=self_attn_mask, dtype=self._dtype) x=self_attn_mask, dtype=self._dtype)
......
...@@ -17,11 +17,13 @@ from __future__ import absolute_import ...@@ -17,11 +17,13 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
import argparse
import collections
import multiprocessing
import os import os
import time import time
import argparse
import numpy as np import numpy as np
import collections
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
......
...@@ -19,6 +19,8 @@ from __future__ import print_function ...@@ -19,6 +19,8 @@ from __future__ import print_function
import numpy as np import numpy as np
from six.moves import xrange
def mask(batch_tokens, def mask(batch_tokens,
seg_labels, seg_labels,
......
...@@ -22,6 +22,8 @@ import numpy as np ...@@ -22,6 +22,8 @@ import numpy as np
import paddle.fluid as fluid import paddle.fluid as fluid
from six.moves import xrange
from model.ernie import ErnieModel from model.ernie import ErnieModel
......
...@@ -25,6 +25,8 @@ import multiprocessing ...@@ -25,6 +25,8 @@ import multiprocessing
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
from six.moves import xrange
from model.ernie import ErnieModel from model.ernie import ErnieModel
def create_model(args, def create_model(args,
......
...@@ -109,7 +109,7 @@ class ErnieModel(object): ...@@ -109,7 +109,7 @@ class ErnieModel(object):
emb_out = pre_process_layer( emb_out = pre_process_layer(
emb_out, 'nd', self._prepostprocess_dropout, name='pre_encoder') emb_out, 'nd', self._prepostprocess_dropout, name='pre_encoder')
if self._dtype is "float16": if self._dtype == "float16":
self_attn_mask = fluid.layers.cast( self_attn_mask = fluid.layers.cast(
x=self_attn_mask, dtype=self._dtype) x=self_attn_mask, dtype=self._dtype)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册