Lesson 2 error: AttributeError: 'AxesImage' object has no property 'rows'

When I run dls.valid.show_batch(max_n=4, rows=1) in the lesson two notebook, I receive a lengthy error that ends with AttributeError: 'AxesImage' object has no property 'rows' (full error message included at the bottom of the post.

This error repeats for cells that use the training set or the validation set.

I’m able to get around the error by removing the row=x argument from the cell, at which point I can run all of the cells and obtain an output consistent with what’s shown in the text.

Is this intended behavior, or am I missing something on my end?

Full error message:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-d24c61455493> in <module>
----> 1 dls.valid.show_batch(max_n=4, rows=1)

/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/data/core.py in show_batch(self, b, max_n, ctxs, show, **kwargs)
     90         if b is None: b = self.one_batch()
     91         if not show: return self._pre_show_batch(b, max_n=max_n)
---> 92         show_batch(*self._pre_show_batch(b, max_n=max_n), ctxs=ctxs, max_n=max_n, **kwargs)
     93 
     94     def show_results(self, b, out, max_n=9, ctxs=None, show=True, **kwargs):

/opt/conda/envs/fastai/lib/python3.7/site-packages/fastcore/dispatch.py in __call__(self, *args, **kwargs)
     96         if not f: return args[0]
     97         if self.inst is not None: f = MethodType(f, self.inst)
---> 98         return f(*args, **kwargs)
     99 
    100     def __get__(self, inst, owner):

/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/vision/data.py in show_batch(x, y, samples, ctxs, max_n, nrows, ncols, figsize, **kwargs)
     43 def show_batch(x:TensorImage, y, samples, ctxs=None, max_n=10, nrows=None, ncols=None, figsize=None, **kwargs):
     44     if ctxs is None: ctxs = get_grid(min(len(samples), max_n), nrows=nrows, ncols=ncols, figsize=figsize)
---> 45     ctxs = show_batch[object](x, y, samples, ctxs=ctxs, max_n=max_n, **kwargs)
     46     return ctxs
     47 

/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/data/core.py in show_batch(x, y, samples, ctxs, max_n, **kwargs)
     13     if ctxs is None: ctxs = Inf.nones
     14     for i in range_of(samples[0]):
---> 15         ctxs = [b.show(ctx=c, **kwargs) for b,c,_ in zip(samples.itemgot(i),ctxs,range(max_n))]
     16     return ctxs
     17 

/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/data/core.py in <listcomp>(.0)
     13     if ctxs is None: ctxs = Inf.nones
     14     for i in range_of(samples[0]):
---> 15         ctxs = [b.show(ctx=c, **kwargs) for b,c,_ in zip(samples.itemgot(i),ctxs,range(max_n))]
     16     return ctxs
     17 

/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/torch_core.py in show(self, ctx, **kwargs)
    296     _show_args = ArrayImageBase._show_args
    297     def show(self, ctx=None, **kwargs):
--> 298         return show_image(self, ctx=ctx, **{**self._show_args, **kwargs})
    299 
    300 # Cell

/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/torch_core.py in show_image(im, ax, figsize, title, ctx, **kwargs)
     52     if figsize is None: figsize = (_fig_bounds(im.shape[0]), _fig_bounds(im.shape[1]))
     53     if ax is None: _,ax = plt.subplots(figsize=figsize)
---> 54     ax.imshow(im, **kwargs)
     55     if title is not None: ax.set_title(title)
     56     ax.axis('off')

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1541     def inner(ax, *args, data=None, **kwargs):
   1542         if data is None:
-> 1543             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1544 
   1545         bound = new_sig.bind(ax, *args, **kwargs)

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs)
    356                 f"%(removal)s.  If any parameter follows {name!r}, they "
    357                 f"should be pass as keyword, not positionally.")
--> 358         return func(*args, **kwargs)
    359 
    360     return wrapper

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs)
    356                 f"%(removal)s.  If any parameter follows {name!r}, they "
    357                 f"should be pass as keyword, not positionally.")
--> 358         return func(*args, **kwargs)
    359 
    360     return wrapper

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/axes/_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
   5611         im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
   5612                               filternorm=filternorm, filterrad=filterrad,
-> 5613                               resample=resample, **kwargs)
   5614 
   5615         im.set_data(X)

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/image.py in __init__(self, ax, cmap, norm, interpolation, origin, extent, filternorm, filterrad, resample, **kwargs)
    897             filterrad=filterrad,
    898             resample=resample,
--> 899             **kwargs
    900         )
    901 

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/image.py in __init__(self, ax, cmap, norm, interpolation, origin, filternorm, filterrad, resample, **kwargs)
    259         self._imcache = None
    260 
--> 261         self.update(kwargs)
    262 
    263     def __getstate__(self):

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/artist.py in update(self, props)
   1004 
   1005         with cbook._setattr_cm(self, eventson=False):
-> 1006             ret = [_update_property(self, k, v) for k, v in props.items()]
   1007 
   1008         if len(ret):

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/artist.py in <listcomp>(.0)
   1004 
   1005         with cbook._setattr_cm(self, eventson=False):
-> 1006             ret = [_update_property(self, k, v) for k, v in props.items()]
   1007 
   1008         if len(ret):

/opt/conda/envs/fastai/lib/python3.7/site-packages/matplotlib/artist.py in _update_property(self, k, v)
   1000                 if not callable(func):
   1001                     raise AttributeError('{!r} object has no property {!r}'
-> 1002                                          .format(type(self).__name__, k))
   1003                 return func(v)
   1004 

AttributeError: 'AxesImage' object has no property 'rows'

1 Like

a git pull should sort it :slight_smile:
rows has become nrows

7 Likes

Thanks for asking this; I was having the same issue!

1 Like

any time! although the git pull is causing issues, as it wants me to commit changes in notebooks, and I’m not entirely sure how to accomplish that yet.

git pull will always want to restore the notebooks to their their “untouched” state, so that’s why it’s asking you to commit your changes. The easiest way around that (which has the intended benefit of making it easy to use the notebooks again for new projects!) is to make a copy of the notebook before using it. In the list of notebooks, there’ll be a box next to the notebook which you can click, and then click “Duplicate” above. So if you make a copy of the notebook as you have it now, then do the git pull, you’ll have both your work and the original. :slight_smile:

1 Like

OH! that’s really helpful! Thank you so much - it solved everything!

1 Like

So glad to help!

1 Like

After doing that. Fixes the first issue but, now get
‘AxesImage’ object has no property ‘unique’

1 Like

Solved here!

2 Likes

thank you!. Note to self… update everything before I begin :slight_smile:

2 Likes

Fast.ai should either change the documentation ASAP, or notify us in a way so that we come to know how to solve the error. Wasted an entire day figuring out what is causing the problem.
Okay it was given nrows in the video only, but the notebook had rows.

Solution: Change rows to nrows. That will solve the problem.

This post helped me get to the source, and if anyone else’s next question is “How do I do a git pull in paperchase gradient?” follow these instructions:

https://course.fast.ai/start_gradient.html#step-3–update-the-fastai-library