PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
rhsu0268 opened this issue · 1 comments
rhsu0268 commented
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 commented
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