Lesson 1 Notebook (Pets NB) - "NoneType" object has no attribute 'show_batch'

Hi everyone! I am trying to run the first lesson. However, after invoking ImageDataBunch.from_name_re() function, I get the following error:

I made sure that regular expression works. I am wondering why data returns None. Any pointers would be helpful. Thank you!

I’m encountering the same problem with the show_batch method. Everything works before it and after it (e.g. print(data.classes), len(data.classes) come out just fine). My errors are in the multiples though:

Does anyone know what’s going on?

RuntimeError Traceback (most recent call last)
in
----> 1 data.show_batch(rows=3, figsize=(7,6))

/anaconda3/lib/python3.7/site-packages/fastai/basic_data.py in show_batch(self, rows, ds_type, **kwargs)
157 def show_batch(self, rows:int=5, ds_type:DatasetType=DatasetType.Train, **kwargs)->None:
158 “Show a batch of data in ds_type on a few rows.”
–> 159 x,y = self.one_batch(ds_type, True, True)
160 n_items = rows **2 if self.train_ds.x._square_show else rows
161 if self.dl(ds_type).batch_size < n_items: n_items = self.dl(ds_type).batch_size

/anaconda3/lib/python3.7/site-packages/fastai/basic_data.py in one_batch(self, ds_type, detach, denorm, cpu)
140 w = self.num_workers
141 self.num_workers = 0
–> 142 try: x,y = next(iter(dl))
143 finally: self.num_workers = w
144 if detach: x,y = to_detach(x,cpu=cpu),to_detach(y,cpu=cpu)

/anaconda3/lib/python3.7/site-packages/fastai/basic_data.py in iter(self)
69 def iter(self):
70 “Process and returns items from DataLoader.”
—> 71 for b in self.dl: yield self.proc_batch(b)
72
73 @classmethod

/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in next(self)
629 while True:
630 assert (not self.shutdown and self.batches_outstanding > 0)
–> 631 idx, batch = self._get_batch()
632 self.batches_outstanding -= 1
633 if idx != self.rcvd_idx:

/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in _get_batch(self)
608 # need to call .task_done() because we don’t use .join().
609 else:
–> 610 return self.data_queue.get()
611
612 def next(self):

/anaconda3/lib/python3.7/multiprocessing/queues.py in get(self, block, timeout)
92 if block and timeout is None:
93 with self._rlock:
—> 94 res = self._recv_bytes()
95 self._sem.release()
96 else:

/anaconda3/lib/python3.7/multiprocessing/connection.py in recv_bytes(self, maxlength)
214 if maxlength is not None and maxlength < 0:
215 raise ValueError(“negative maxlength”)
–> 216 buf = self._recv_bytes(maxlength)
217 if buf is None:
218 self._bad_message_length()

/anaconda3/lib/python3.7/multiprocessing/connection.py in _recv_bytes(self, maxsize)
405
406 def _recv_bytes(self, maxsize=None):
–> 407 buf = self._recv(4)
408 size, = struct.unpack("!i", buf.getvalue())
409 if maxsize is not None and size > maxsize:

/anaconda3/lib/python3.7/multiprocessing/connection.py in _recv(self, size, read)
377 remaining = size
378 while remaining > 0:
–> 379 chunk = read(handle, remaining)
380 n = len(chunk)
381 if n == 0:

/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in handler(signum, frame)
272 # This following call uses waitid with WNOHANG from C side. Therefore,
273 # Python can still get and update the process status successfully.
–> 274 _error_if_any_worker_fails()
275 if previous_handler is not None:
276 previous_handler(signum, frame)

RuntimeError: DataLoader worker (pid 8816) is killed by signal: Unknown signal: 0.

I fixed my issue by moving the normalize() call and putting it into a newline because normalize() does not return a value. Also, I would consider updating your version of fastai library.

1 Like