shensq04 / EKLAVYA

56 stars 16 forks source link

why save_embeddings.py use python2 while train_embed.py use python3? #2

Closed qingbol closed 4 years ago

qingbol commented 4 years ago

why save_embeddings.py use python2 while train_embed.py use python3? when i run save_embeddings.py, below error occurs:

Model loaded Loading embed input data... Traceback (most recent call last): File "save_embeddings.py", line 113, in main() File "save_embeddings.py", line 54, in main input_data = pickle.load(open(embed_pickle_path)) File "/home/qingbol/.conda/envs/tf12gpu_py27/lib/python2.7/pickle.py", line 1384, in load return Unpickler(file).load() File "/home/qingbol/.conda/envs/tf12gpu_py27/lib/python2.7/pickle.py", line 864, in load dispatchkey File "/home/qingbol/.conda/envs/tf12gpu_py27/lib/python2.7/pickle.py", line 892, in load_proto raise ValueError, "unsupported pickle protocol: %d" % proto ValueError: unsupported pickle protocol: 3

melynx commented 4 years ago

Probably because you ran train_embed using python3? You can execute the script by specifying the python interpreter or change the #! interpreter directive.

qingbol commented 4 years ago

Probably because you ran train_embed using python3? You can execute the script by specifying the python interpreter or change the #! interpreter directive.

Yes, I ran train_embed.py in python3.6 and tensorflow1.12. In tensorflow1.12, the method to import gen_word2vec already changed. The reason I ran train_embed.py in python3.6 is because train_embed.py script is based on python3, you can tell from it's print statements. I found that only the print statements in save_embeddings.py is written in python2 style.

could you provide the specific version of python and tensorflow to run this project? Appreciate your reply.

melynx commented 4 years ago

If I remember correctly, we ran it with python2.7 using tensorflow 0.12. Python2.7 supports both the print function and statement. Or you can just choose to pickle it using the 2.0 protocol instead of 3.0.