Having trouble duplicating results in Examples

I just updated fastai today and I’m getting some goofy errors while trying to duplicate results in the documentation (I’m just running examples at the moment).

My current install:

=== Software === 
python version  : 3.7.0
fastai version  : 1.0.35.dev0
torch version   : 1.0.0.dev20181022
nvidia driver   : 396.54
torch cuda ver  : 9.2.148
torch cuda is   : available
torch cudnn ver : 7104
torch cudnn is  : enabled

=== Hardware === 
nvidia gpus     : 1
torch available : 1
  - gpu0        : 11441MB | Tesla K80

=== Environment === 
platform        : Linux-4.15.0-1025-gcp-x86_64-with-debian-buster-sid
distro          : Ubuntu 18.04 Bionic Beaver
conda env       : Unknown
python          : /home/beehollander/anaconda3/envs/fastai-v1/bin/python
sys.path        : 
/home/beehollander/fastai/examples
/home/beehollander/anaconda3/envs/fastai-v1/lib/python37.zip
/home/beehollander/anaconda3/envs/fastai-v1/lib/python3.7
/home/beehollander/anaconda3/envs/fastai-v1/lib/python3.7/lib-dynload
/home/beehollander/anaconda3/envs/fastai-v1/lib/python3.7/site-packages
/home/beehollander/fastai
/home/beehollander/anaconda3/envs/fastai-v1/lib/python3.7/site-packages/IPython/extensions
/home/beehollander/.ipython

Fri Dec  7 18:36:03 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.54                 Driver Version: 396.54                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           Off  | 00000000:00:04.0 Off |                    0 |
| N/A   72C    P0    76W / 149W |    302MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      3754      C   ...der/anaconda3/envs/fastai-v1/bin/python   291MiB |
+-----------------------------------------------------------------------------+

In the tabular example, when it tries to run learn.fit it gives me this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-c6076a6ce3f3> in <module>
----> 1 learn.fit(1, 1e-2)

~/fastai/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
    164         callbacks = [cb(self) for cb in self.callback_fns] + listify(callbacks)
    165         fit(epochs, self.model, self.loss_func, opt=self.opt, data=self.data, metrics=self.metrics,
--> 166             callbacks=self.callbacks+callbacks)
    167 
    168     def create_opt(self, lr:Floats, wd:Floats=0.)->None:

~/fastai/fastai/basic_train.py in fit(epochs, model, loss_func, opt, data, callbacks, metrics)
     72     cb_handler = CallbackHandler(callbacks, metrics)
     73     pbar = master_bar(range(epochs))
---> 74     cb_handler.on_train_begin(epochs, pbar=pbar, metrics=metrics)
     75 
     76     exception=False

~/fastai/fastai/callback.py in on_train_begin(self, epochs, pbar, metrics)
    193         self.state_dict['n_epochs'],self.state_dict['pbar'],self.state_dict['metrics'] = epochs,pbar,metrics
    194         names = [(met.name if hasattr(met, 'name') else camel2snake(met.__class__.__name__)) for met in self.metrics]
--> 195         self('train_begin', metrics_names=names)
    196 
    197     def on_epoch_begin(self)->None:

~/fastai/fastai/callback.py in __call__(self, cb_name, call_mets, **kwargs)
    186         "Call through to all of the `CallbakHandler` functions."
    187         if call_mets: [getattr(met, f'on_{cb_name}')(**self.state_dict, **kwargs) for met in self.metrics]
--> 188         return [getattr(cb, f'on_{cb_name}')(**self.state_dict, **kwargs) for cb in self.callbacks]
    189 
    190     def on_train_begin(self, epochs:int, pbar:PBar, metrics:MetricFuncList)->None:

~/fastai/fastai/callback.py in <listcomp>(.0)
    186         "Call through to all of the `CallbakHandler` functions."
    187         if call_mets: [getattr(met, f'on_{cb_name}')(**self.state_dict, **kwargs) for met in self.metrics]
--> 188         return [getattr(cb, f'on_{cb_name}')(**self.state_dict, **kwargs) for cb in self.callbacks]
    189 
    190     def on_train_begin(self, epochs:int, pbar:PBar, metrics:MetricFuncList)->None:

~/fastai/fastai/basic_train.py in on_train_begin(self, pbar, metrics_names, **kwargs)
    329         self.names += metrics_names
    330         if hasattr(self, '_added_met_names'): self.names += self._added_met_names
--> 331         self.pbar.write(self.names, table=True)
    332         self.losses,self.val_losses,self.lrs,self.moms,self.metrics,self.nb_batches = [],[],[],[],[],[]
    333 

~/anaconda3/envs/fastai-v1/lib/python3.7/site-packages/fastprogress/fastprogress.py in write(self, line, table)
    223         if not table: self.text += line + "<p>"
    224         else:
--> 225             self.raw_text += line + "\n"
    226             self.text = text2html_table(self.raw_text)
    227 

TypeError: can only concatenate list (not "str") to list

And then in the dogs_cats example, it gives me this error when it tries to run img.show(title=data.classes[label]):

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-e4a591a007cd> in <module>
----> 1 img.show(title=data.classes[label])

TypeError: list indices must be integers or slices, not Category

The reason for the Category error is probably because label is defined above it by:
img,label = data.valid_ds[-1] and so that’s returning a Category and not an index like this code was written for.

Did I miss something? It feels like there was some change that I didn’t hear about and now so much has changed even since the last lesson. Are things simply changing so often that there’s month-old code that’s stale now? The cats_dogs notebook was updated 28 days ago and the tabular one less than that. I don’t want to tell anybody to slow down, but there seems to be so much change that it’s hard to hang on to what WON’T change.

It’s doing it in the rossman notebook from lesson 6 as well when it runs learn.lr_find().
Anybody? @sgugger?

It seems to be coming from fastprogress.py at the end. It gives this error with/without passing any metrics into the learner creation.

I updated to fastai version 35 and it seems to be working now. Still not sure I understand what went wrong.

=== Software === 
python version  : 3.7.0
fastai version  : 1.0.35.dev0
torch version   : 1.0.0.dev20181022
nvidia driver   : 396.54
torch cuda ver  : 9.2.148
torch cuda is   : available
torch cudnn ver : 7104
torch cudnn is  : enabled

=== Hardware === 
nvidia gpus     : 1
torch available : 1
  - gpu0        : 11441MB | Tesla K80

=== Environment === 
platform        : Linux-4.15.0-1025-gcp-x86_64-with-debian-buster-sid
distro          : Ubuntu 18.04 Bionic Beaver
conda env       : Unknown
python          : /home/beehollander/anaconda3/envs/fastai-v1/bin/python
sys.path        : 
/home/beehollander/course-v3/nbs/dl1
/home/beehollander/anaconda3/envs/fastai-v1/lib/python37.zip
/home/beehollander/anaconda3/envs/fastai-v1/lib/python3.7
/home/beehollander/anaconda3/envs/fastai-v1/lib/python3.7/lib-dynload
/home/beehollander/anaconda3/envs/fastai-v1/lib/python3.7/site-packages
/home/beehollander/fastai
/home/beehollander/anaconda3/envs/fastai-v1/lib/python3.7/site-packages/IPython/extensions
/home/beehollander/.ipython

Fri Dec  7 21:33:18 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.54                 Driver Version: 396.54                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           Off  | 00000000:00:04.0 Off |                    0 |
| N/A   73C    P0    76W / 149W |    620MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      3754      C   ...der/anaconda3/envs/fastai-v1/bin/python   291MiB |
|    0      3900      C   ...der/anaconda3/envs/fastai-v1/bin/python   316MiB |
+-----------------------------------------------------------------------------+

Nevermind. It’s still in MY notebook, just not the example. Same error as above about only concatenating lists.

Also, creating my databunch doesn’t give me an error until I try to show_batch.
Code:

data = (TabularList.from_df(train, path=path, cat_names=cat_names, procs=procs)
           .random_split_by_pct()
           .label_from_df(cols=dep_var)
           .databunch())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-74-0ef5bf68f37d> in <module>
----> 1 data.show_batch(rows=10)

~/fastai/fastai/basic_data.py in show_batch(self, rows, ds_type, **kwargs)
    158             ys = [self.train_ds.y.reconstruct(grab_idx(y, i), x=x) for i,x in enumerate(xs)]
    159         else : ys = [self.train_ds.y.reconstruct(grab_idx(y, i)) for i in range(rows)]
--> 160         self.train_ds.x.show_xys(xs, ys, **kwargs)
    161 
    162     def export(self, fname:str='export.pkl'):

~/fastai/fastai/tabular/data.py in show_xys(self, xs, ys)
    137             for c, n in zip(x.cats, x.names[:len(x.cats)]):
    138                 res.append(str(x.classes[n][c]))
--> 139             res += [f'{c:.4f}' for c in x.conts] + [str(y)]
    140             items.append(res)
    141         display(HTML(text2html_table(items, [10] * len(items[0]))))

~/anaconda3/envs/fastai-v1/lib/python3.7/site-packages/torch/tensor.py in __iter__(self)
    413         # map will interleave them.)
    414         if self.dim() == 0:
--> 415             raise TypeError('iteration over a 0-d tensor')
    416         if torch._C._get_tracing_state():
    417             warnings.warn('Iterating over a tensor might cause the trace to be incorrect. '

TypeError: iteration over a 0-d tensor

The first one comes from the fact you don’t have the latest version of fastprogress, so you should upgrade it. Not sure where the other ones come from.