Commit 160b5d60 authored by thomwolf's avatar thomwolf
Browse files

fix xlm lang_embeddings loading

parent 26497d11
...@@ -47,10 +47,13 @@ TF_XLM_PRETRAINED_MODEL_ARCHIVE_MAP = { ...@@ -47,10 +47,13 @@ TF_XLM_PRETRAINED_MODEL_ARCHIVE_MAP = {
def load_xlm_pt_weights_in_tf2(tf_model, pytorch_checkpoint_path): def load_xlm_pt_weights_in_tf2(tf_model, pytorch_checkpoint_path):
# build the network # build the network
inputs_list = [[7, 6, 0, 0, 1], [1, 2, 3, 0, 0], [0, 0, 0, 4, 5]] inputs_list = tf.constant([[7, 6, 0, 0, 1], [1, 2, 3, 0, 0], [0, 0, 0, 4, 5]])
attns_list = [[1, 1, 0, 0, 1], [1, 1, 1, 0, 0], [1, 0, 0, 1, 1]] attns_list = tf.constant([[1, 1, 0, 0, 1], [1, 1, 1, 0, 0], [1, 0, 0, 1, 1]])
langs_list = [[1, 1, 0, 0, 1], [1, 1, 1, 0, 0], [1, 0, 0, 1, 1]] if tf_model.config.use_lang_emb and tf_model.config.n_langs > 1:
tf_inputs = [tf.constant(inputs_list), tf.constant(attns_list), tf.constant(langs_list)] langs_list = tf.constant([[1, 1, 0, 0, 1], [1, 1, 1, 0, 0], [1, 0, 0, 1, 1]])
else:
langs_list = None
tf_inputs = [inputs_list, attns_list), langs_list]
tfo = tf_model(tf_inputs, training=False) tfo = tf_model(tf_inputs, training=False)
return load_pytorch_checkpoint_in_tf2_model(tf_model, pytorch_checkpoint_path, tf_inputs=tf_inputs) return load_pytorch_checkpoint_in_tf2_model(tf_model, pytorch_checkpoint_path, tf_inputs=tf_inputs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment