Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target_params.pkl open using pyhotn3 pickle failed. #15

Closed
lucasjinreal opened this issue May 8, 2017 · 6 comments
Closed

target_params.pkl open using pyhotn3 pickle failed. #15

lucasjinreal opened this issue May 8, 2017 · 6 comments

Comments

@lucasjinreal
Copy link

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
Copy link
Owner

LantaoYu commented May 9, 2017

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

try:
    import cPickle as pickle
except:
    import pickle

@rahulptel
Copy link

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
Copy link
Author

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
Copy link
Owner

LantaoYu commented May 10, 2017

This should work:

import pickle
target_params = pickle.load(open('save/target_params.pkl', 'rb'), encoding='latin1')

@rahulptel
Copy link

Still not working.

@LantaoYu
Copy link
Owner

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'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants