Training fails for language model and text classfier with numpy v1.16

I am using fastai v0.7 with numpy v1.15+ and noticed that my tests started to fail when numpy recently bumped to v1.16. The relevant part of the error look like this:

../../../virtualenv/python3.6.3/lib/python3.6/site-packages/fastai/learner.py:287: in fit
    return self.fit_gen(self.model, self.data, layer_opt, n_cycle, **kwargs)
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/fastai/learner.py:234: in fit_gen
    swa_eval_freq=swa_eval_freq, **kwargs)
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/fastai/model.py:160: in fit
    print_stats(epoch, [debias_loss] + vals)
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/fastai/model.py:173: in print_stats
    values = [epoch] + list(np.round(values, decimals))
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/numpy/core/fromnumeric.py:3382: in round_
    return around(a, decimals=decimals, out=out)
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/numpy/core/fromnumeric.py:3007: in around
    return _wrapfunc(a, 'round', decimals=decimals, out=out)
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/numpy/core/fromnumeric.py:66: in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
obj = [4.57860245691305, array([4.04758]), 0.24526315789473685]
method = 'round', args = (), kwds = {'decimals': 6, 'out': None}, wrap = None
    def _wrapit(obj, method, *args, **kwds):
        try:
            wrap = obj.__array_wrap__
        except AttributeError:
            wrap = None
>       result = getattr(asarray(obj), method)(*args, **kwds)
E       AttributeError: 'float' object has no attribute 'rint'
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/numpy/core/fromnumeric.py:46: AttributeError

I can make do fine with pinning numpy to v1.15, but just wanted to put this out here for others.

3 Likes

I am facing the same. How did you resolve the error:

name ‘os_fspath’ is not defined

when entering the command

spacy_tok = spacy.load(‘en’)

Hi. I never really faced this problem. The tokenizer works fine for me.

@salmanmaq: I’ve run into a similar kind of issue. Could you kindly explain how you downgraded numpy to v.1.15+.
Thanks :slight_smile:

I use pip and virtualenv, so I just uninstalled numpy, and then did pip install numpy==1.15

1 Like

@salmanmaq Wish had read this earlier. Training failed after 4 hours. Any other version issues I can prevent ?

Thanks @salmanmaq :+1:

You can check out the version we use here: https://github.com/inspirehep/inspire-classifier/blob/master/setup.py

Some of them are auxillary libraries for our application and don’t have much to do with fastai. I would mostly be concerned about numpy, torchtext, and spacy from the list.