Can't get attribute 'NativeMixedPrecision' error

I’m working on a model for Image Classification on Kaggle, I created a Learner with .to_native_fp16(). After training i saved it with to later load it and train it further but the results weren’t getting better so I just stuck with the saved one. I loaded it with learn.load() the next day and I exported it for inference. When I try to load it in a different kernel using load_learner I get the following error:
AttributeError Traceback (most recent call last)
----> 1 learn = load_learner(Path(’…/input/89acc-effnet/89acc’), cpu=False).to_native_fp32()

/opt/conda/lib/python3.7/site-packages/fastai/ in load_learner(fname, cpu, pickle_module)
    372     "Load a `Learner` object in `fname`, optionally putting it on the `cpu`"
    373     distrib_barrier()
--> 374     res = torch.load(fname, map_location='cpu' if cpu else None, pickle_module=pickle_module)
    375     if hasattr(res, 'to_fp32'): res = res.to_fp32()
    376     if cpu: res.dls.cpu()

/opt/conda/lib/python3.7/site-packages/torch/ in load(f, map_location, pickle_module, **pickle_load_args)
    593                     return torch.jit.load(opened_file)
--> 594                 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
    595         return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)

/opt/conda/lib/python3.7/site-packages/torch/ in _load(zip_file, map_location, pickle_module, pickle_file, **pickle_load_args)
    851     unpickler = pickle_module.Unpickler(data_file, **pickle_load_args)
    852     unpickler.persistent_load = persistent_load
--> 853     result = unpickler.load()
    855     torch._utils._validate_loaded_sparse_tensors()

AttributeError: Can't get attribute 'NativeMixedPrecision' on <module 'fastai.callback.fp16' from '/opt/conda/lib/python3.7/site-packages/fastai/callback/'>`

This seemed to have changed in fastai 2.2.0.

Promote NativeMixedPrecision to default MixedPrecision (and similar for Learner.to_fp16 ); old MixedPrecision is now called NonNativeMixedPrecision

1 Like

what is diff between

Dring inference what should we do to export weights to fp32

for the second question, try learn.to_fp32()?