How to load pretrained word2vec embedding files with opennmt-tf?


when I try to use the embedding files like below:

src_embedding: ../data/word2vec_vectors.en
tgt_embedding: ../data/word2vec_vectors.zh

Errors occurs:

Traceback (most recent call last):
  File "/anaconda3/lib/python3.6/site-packages/opennmt/inputters/", line 355, in transform
    embeddings = tf.get_variable("w_embs", dtype=self.dtype, trainable=self.trainable)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/", line 1487, in get_variable
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/", line 1237, in get_variable
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/", line 540, in get_variable
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/", line 492, in _true_getter
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/", line 904, in _get_single_variable
ValueError: You can only pass an initializer function that expects no arguments to its callable when the shape is not fully defined. The given initializer function expects the following args ['self', 'shape', 'dtype', 'partition_info']

During handling of the above exception, another exception occurred:

Here is my question:
Maybe the word2vec embedding files can not be used directly, how to use the word2vec embedding ?

Thanks very much!


  • What is your TensorFlow version?
  • What is your model configuration?
  • Is this error occurring during the initial training?