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

TypeError: cannot pickle '_thread.RLock' object #14180

Closed
GOURAVSUMAN opened this issue Aug 1, 2020 · 11 comments
Closed

TypeError: cannot pickle '_thread.RLock' object #14180

GOURAVSUMAN opened this issue Aug 1, 2020 · 11 comments
Assignees
Labels
stat:awaiting response from contributor type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.

Comments

@GOURAVSUMAN
Copy link

*TypeError: cannot pickle '_thread.RLock' object
TypeError Traceback (most recent call last)
in
----> 1 pickle.dump(learner, open('model.pkl','wb'))
2
3 model = pickle.load(open('model.pkl','rb'))
4 print(model.predict([['GST TDS RETURN', 'Tax teturn filled', 'Good bless u']]))

TypeError: cannot pickle '_thread.RLock' object

image

@saikumarchalla saikumarchalla added the type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited. label Aug 10, 2020
@stacy-ojwang
Copy link

i am having the same issue. Can someone please assist.

@tkmamidi
Copy link

@itsrawlinz-jeff
Copy link

Same issue..Who's got a solution

@rohitnishad613
Copy link

I have the same issue too.

@HeinrichWizardKreuser
Copy link

has anyone found a fix for this yet? I'm not even using multiprocessing

@Gourav-infobiz
Copy link

has anyone found a fix for this yet? I'm not even using multiprocessing

Can you please share full error details and the code where you got this error.

@tkmamidi
Copy link

tkmamidi commented Dec 15, 2020

Maybe follow this -
https://medium.com/fintechexplained/how-to-save-trained-machine-learning-models-649c3ad1c018

As mentioned in this link, you can save and load keras models without using pickle.

Save the model:

# serialize to JSON
json_file = model.to_json()
with open(json_file_path, "w") as file:
   file.write(json_file)
# serialize weights to HDF5
model.save_weights(h5_file)

Load the model:

# load json and create model
file = open(json_file, 'r')
model_json = file.read()
file.close()
loaded_model = model_from_json(model_json)
# load weights
loaded_model.load_weights(h5_file)

Hope this helps!

@tkmamidi
Copy link

This is as other way to do it -

model.save("my_model")
model.save_weights("weights.h5")

from tensorflow import keras
my_model = keras.models.load_model('my_model')
my_model.load_weights("weights.h5")

@sushreebarsa
Copy link
Contributor

@GOURAVSUMAN could you please try as per the above comment and let us know if this issue still persists ? Thanks !

@sushreebarsa
Copy link
Contributor

Closing this issue due to lack of recent activity .Please feel free to reopen if you still have concern.Thanks!

@Lord-O-Binary
Copy link

This is as other way to do it -

model.save("my_model")
model.save_weights("weights.h5")

from tensorflow import keras
my_model = keras.models.load_model('my_model')
my_model.load_weights("weights.h5")

I can confirm saving as json with weights file fixes the threading issue during deepcopy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting response from contributor type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.
Projects
None yet
Development

No branches or pull requests

10 participants