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

PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed #10

Open
rhsu0268 opened this issue Dec 3, 2017 · 1 comment

Comments

@rhsu0268
Copy link

rhsu0268 commented Dec 3, 2017

Hi.

I am trying to follow your README to train a model and I seem to be getting the following error:

PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup builtin.instancemethod failed

I tried going to keras version 1 but it still doesn't seem to be happy. The problem seems to be with this: model.fit_generator(train_generator,
validation_data=None,
validation_steps=X_test.shape[0],
steps_per_epoch=X_train.shape[0],
epochs=32,
verbose=2,
callbacks=None)
Can you let me know if I'm doing something wrong?

@sagarmk
Copy link

sagarmk commented Jan 23, 2018

Add

import copy_reg
import types
import multiprocessing

def _pickle_method(m):
    if m.im_self is None:
        return getattr, (m.im_class, m.im_func.func_name)
    else:
        return getattr, (m.im_self, m.im_func.func_name)

copy_reg.pickle(types.MethodType, _pickle_method)

on that beginning of that code block and it should work fine

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

2 participants