LantaoYu / SeqGAN

Implementation of Sequence Generative Adversarial Nets with Policy Gradient
2.09k stars 710 forks source link

target_params.pkl open using pyhotn3 pickle failed. #15

Closed lucasjinreal closed 7 years ago

lucasjinreal commented 7 years ago

hi, I am trying run this repo under pyhton3, original implements using python2, code is fine but the target_params.pkl can not open, do you have an alternate version of that file which can open using python3?

LantaoYu commented 7 years ago

I think you can use pickle in python 3 instead of cPickle:

try:
    import cPickle as pickle
except:
    import pickle
rahulptel commented 7 years ago

I tried the same but it's not working.

Improved the code to target_params = pickle.load(open('save/target_params.pkl','rb')) .

Gives the following error: ImportError: No module named 'numpy.core.multiarray\r'

Tried to resolve the \r issue using this answer.

Yet the issue remains. Get this message. TypeError: a bytes-like object is required, not 'str'

Can we create a new pickle for python 3 to resolve them?

lucasjinreal commented 7 years ago

I think original author save the data using python2.7 cPickle which may not can be properly opened by Python3 pickle, would original author resave this file using python3 for compatiable?

LantaoYu commented 7 years ago

This should work:

import pickle
target_params = pickle.load(open('save/target_params.pkl', 'rb'), encoding='latin1')
rahulptel commented 7 years ago

Still not working.

LantaoYu commented 7 years ago

I have added a new pickle file in python 3: https://github.com/LantaoYu/SeqGAN/blob/master/save/target_params_py3.pkl

Now you can read it with

import pickle
target_params = pickle.load(open('target_params_py3.pkl', 'rb'))