when runing the code below
print(‘Saving best accuracy…’)
state = {
‘model’: model.modules,
‘best_acc’: test_best_acc,
‘epoch’: epoch
}
if not os.path.isdir(‘checkpoint’):
os.mkdir(‘checkpoint’)
torch.save(state, ‘checkpoint/ckpt.t7’)
it happens
PicklingError                             Traceback (most recent call last)
 in ()
64 for epoch in range(1, 300):
65     train_epoch(epoch, baseCNN, train_loader, rms_baseCNN, cross_entropy)
—> 66     vali_epoch(epoch, baseCNN, vali_loader, cross_entropy)
 in vali_epoch(epoch, model, data_loader, criterion)
59         if not os.path.isdir(‘checkpoint’):
60             os.mkdir(‘checkpoint’)
—> 61         torch.save(state, ‘checkpoint/ckpt.t7’)
62
63
/usr/local/anaconda2/lib/python2.7/site-packages/torch/serialization.pyc in save(obj, f, pickle_module, pickle_protocol)
118         f = open(f, “wb”)
119     try:
–> 120         return _save(obj, f, pickle_module, pickle_protocol)
121     finally:
122         if new_fd:
/usr/local/anaconda2/lib/python2.7/site-packages/torch/serialization.pyc in _save(obj, f, pickle_module, pickle_protocol)
184     pickler = pickle_module.Pickler(f, protocol=pickle_protocol)
185     pickler.persistent_id = persistent_id
–> 186     pickler.dump(obj)
187
188     serialized_storage_keys = sorted(serialized_storages.keys())
PicklingError: Can’t pickle <type ‘instancemethod’>: attribute lookup builtin.instancemethod failed
So how can I solve this problem? Thanking very much