Repository: OpenNMT/OpenNMT-py

Issue:
Error when using ./tools/embeddings_to_torch.py
**I am getting the following error.
Is it harmful and anyone know how to solve it?**


[2018-09-24 21:06:09,964 INFO] From: ./glove_experiment/data.vocab.pt
[2018-09-24 21:06:09,964 INFO] 	* source vocab: 50002 words
[2018-09-24 21:06:09,964 INFO] 	* target vocab: 50004 words
[2018-09-24 21:06:42,008 INFO] Got 400000 encryption embeddings from ./glove/original.txt
[2018-09-24 21:08:21,394 INFO] Got 1142358 decryption embeddings from ./glove/wiki.fr.vec
[2018-09-24 21:08:21,699 INFO] 
Matching: 
[2018-09-24 21:08:21,699 INFO] 	* enc: 19625 match, 30377 missing, (39.25%)
[2018-09-24 21:08:21,699 INFO] 	* dec: 1071 match, 48933 missing, (2.14%)
[2018-09-24 21:08:21,699 INFO] 
Filtered embeddings:
--- Logging error ---
Traceback (most recent call last):
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 993, in emit
    msg = self.format(record)
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 839, in format
    return fmt.format(record)
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 576, in format
    record.message = record.getMessage()
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 338, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "./tools/embeddings_to_torch.py", line 148, in <module>
    main()
  File "./tools/embeddings_to_torch.py", line 134, in main
    logger.info("\t* enc: ", filtered_enc_embeddings.size())
Message: '\t* enc: '
Arguments: (torch.Size([50002, 300]),)
--- Logging error ---
Traceback (most recent call last):
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 993, in emit
    msg = self.format(record)
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 839, in format
    return fmt.format(record)
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 576, in format
    record.message = record.getMessage()
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 338, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "./tools/embeddings_to_torch.py", line 148, in <module>
    main()
  File "./tools/embeddings_to_torch.py", line 134, in main
    logger.info("\t* enc: ", filtered_enc_embeddings.size())
Message: '\t* enc: '
Arguments: (torch.Size([50002, 300]),)
--- Logging error ---
Traceback (most recent call last):
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 993, in emit
    msg = self.format(record)
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 839, in format
    return fmt.format(record)
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 576, in format
    record.message = record.getMessage()
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 338, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "./tools/embeddings_to_torch.py", line 148, in <module>
    main()
  File "./tools/embeddings_to_torch.py", line 135, in main
    logger.info("\t* dec: ", filtered_dec_embeddings.size())
Message: '\t* dec: '
Arguments: (torch.Size([50004, 300]),)
--- Logging error ---
Traceback (most recent call last):
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 993, in emit
    msg = self.format(record)
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 839, in format
    return fmt.format(record)
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 576, in format
    record.message = record.getMessage()
  File "/home/eeb439/anaconda3/envs/pytorch0.4text0.3/lib/python3.6/logging/__init__.py", line 338, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "./tools/embeddings_to_torch.py", line 148, in <module>
    main()
  File "./tools/embeddings_to_torch.py", line 135, in main
    logger.info("\t* dec: ", filtered_dec_embeddings.size())
Message: '\t* dec: '
Arguments: (torch.Size([50004, 300]),)
[2018-09-24 21:08:21,701 INFO] 
Saving embedding as:
	* enc: ./glove_experiment/embeddings.enc.pt
	* dec: ./glove_experiment/embeddings.dec.pt
[2018-09-24 21:08:22,065 INFO] 
Done.



Discussion:

Resolving patch:
diff --git a/tools/embeddings_to_torch.py b/tools/embeddings_to_torch.py
--- a/tools/embeddings_to_torch.py
+++ b/tools/embeddings_to_torch.py
@@ -127,8 +127,8 @@ def main():
                    match_percent[1]))
 
     logger.info("\nFiltered embeddings:")
-    logger.info("\t* enc: ", filtered_enc_embeddings.size())
-    logger.info("\t* dec: ", filtered_dec_embeddings.size())
+    logger.info("\t* enc: %s" % str(filtered_enc_embeddings.size()))
+    logger.info("\t* dec: %s" % str(filtered_dec_embeddings.size()))
 
     enc_output_file = opt.output_file + ".enc.pt"
     dec_output_file = opt.output_file + ".dec.pt"


Test patch: