Intro to ML (lesson 8): AttributeError: 'float' object has no attribute 'rint'


(chaouki) #1

Hi,

I’m running the following code under the fastai-cpu:

net = nn.Sequential(
nn.Linear(28*28, 100),
nn.ReLU(),
nn.Linear(100, 100),
nn.ReLU(),
nn.Linear(100, 10),
nn.LogSoftmax()
)

When I tried the following command:
fit(net, md, n_epochs=5, crit=loss, opt=opt, metrics=metrics)

I got the following error:


AttributeError Traceback (most recent call last)
~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
55 try:
—> 56 return getattr(obj, method)(*args, **kwds)
57

AttributeError: ‘list’ object has no attribute ‘round’

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
in
----> 1 fit(net, md, n_epochs=5, crit=loss, opt=opt, metrics=metrics)

~/fastai/courses/ml1/fastai/model.py in fit(model, data, n_epochs, opt, crit, metrics, callbacks, stepper, swa_model, swa_start, swa_eval_freq, visualize, **kwargs)
173 else:
174 print(layout.format(*names))
–> 175 print_stats(epoch, [debias_loss] + vals, visualize)
176 prev_val = [debias_loss] + vals
177 ep_vals = append_stats(ep_vals, epoch, [debias_loss] + vals)

~/fastai/courses/ml1/fastai/model.py in print_stats(epoch, values, visualize, prev_val, decimals)
187 def print_stats(epoch, values, visualize, prev_val=[], decimals=6):
188 layout = “{!s:^10}” + " {!s:10}" * len(values)
–> 189 values = [epoch] + list(np.round(values, decimals))
190 sym = “”
191 if visualize:

~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in round_(a, decimals, out)
3380 around : equivalent function; see for details.
3381 “”"
-> 3382 return around(a, decimals=decimals, out=out)
3383
3384

~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in around(a, decimals, out)
3005
3006 “”"
-> 3007 return _wrapfunc(a, ‘round’, decimals=decimals, out=out)
3008
3009

~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
64 # a downstream library like ‘pandas’.
65 except (AttributeError, TypeError):
—> 66 return _wrapit(obj, method, *args, **kwds)
67
68

~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapit(obj, method, *args, **kwds)
44 except AttributeError:
45 wrap = None
—> 46 result = getattr(asarray(obj), method)(*args, **kwds)
47 if wrap:
48 if not isinstance(result, mu.ndarray):

AttributeError: ‘float’ object has no attribute ‘rint’

Can someone point me in the right direction to figure out why this is happening?
Thanks!


(Tom Halasz) #2

Hi, I also ran into this error while running the fit( ) method in a cell for Deep Learning 2018 “lesson6-rnn” notebook. I had just done “conda env update” beforehand, so apparently a numpy update has rendered the old code useless. Yesterday, I ran the same notebook without throwing the error, which is the same as yours.

I wish I had an answer for you, Chaouki, but I’m in over my head. I regret doing the update, is all I can say!

Tried following this advice: Unfamiliar Error when Running learn.fit()

Unfortunately, it still throws an error that I won’t bother to describe.


(chaouki) #3

Thanks @thalasz :slight_smile: