I’m getting the following error when trying to export the model
Running on colab with versions:
fastai version 0.0.16 pytorch version 1.4.0
initialized the learn object as follows:
learn = cnn_learner(dls,
partial(arch,pretrained=pretrained),
metrics=metrics,
cbs=cbs)
and dls as follows
def splitter(df):
train = df.index[df['is_valid']==False].tolist()
valid = df.index[df['is_valid']==True].tolist()
# print("train",train[:10],"valid",valid[:10])
return train,valid
def get_x(r): return r['name']
def get_y(r):
rv = r['label'].split(" ")
if "" in rv:
while "" in rv:
rv.remove("")
return rv
dblock = DataBlock(blocks=(ImageBlock, MultiCategoryBlock),
splitter=splitter,
get_x = get_x,
get_y = get_y,
item_tfms = RandomResizedCrop(256, min_scale=0.08),
batch_tfms=augs)
bs=64
dls = dblock.dataloaders(df,bs=bs)
Error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-66-fa5b61306ef3> in <module>()
----> 1 learn.export()
2 frames
/usr/local/lib/python3.6/dist-packages/fastai2/learner.py in export(self, fname, pickle_protocol)
497 #To avoid the warning that come from PyTorch about model not being checked
498 warnings.simplefilter("ignore")
--> 499 torch.save(self, self.path/fname, pickle_protocol=pickle_protocol)
500 self.create_opt()
501 if state is not None: self.opt.load_state_dict(state)
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in save(obj, f, pickle_module, pickle_protocol, _use_new_zipfile_serialization)
326
327 with _open_file_like(f, 'wb') as opened_file:
--> 328 _legacy_save(obj, opened_file, pickle_module, pickle_protocol)
329
330
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in _legacy_save(obj, f, pickle_module, pickle_protocol)
399 pickler = pickle_module.Pickler(f, protocol=pickle_protocol)
400 pickler.persistent_id = persistent_id
--> 401 pickler.dump(obj)
402
403 serialized_storage_keys = sorted(serialized_storages.keys())
AttributeError: Can't pickle local object 'combine_scheds.<locals>._inner'
Appreciate any help, Thanks!