title: AttributeError: Caught AttributeError in DataLoader worker process 0
body: <p>I have done some googling, and this error seems to commonly appear but I am unsure about how to solve it/ I am currently doing the PyTorch torchvision tutorial (<a href="https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html" rel="nofollow noreferrer">https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html</a>) for segmentation. However, I am getting thrown the titular error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;main.py&quot;, line 139, in &lt;module&gt;
      main()
    File &quot;main.py&quot;, line 131, in main
      print_freq=10)
    File &quot;/engine.py&quot;, line 26, in train_one_epoch
      for images, targets in metric_logger.log_every(data_loader, print_freq, header):
    File &quot;/utils.py&quot;, line 180, in log_every
      for obj in iterable:
    File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py&quot;, line 521, in __next__
      data = self._next_data()
    File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py&quot;, line 1203, in _next_data
      return self._process_data(data)
    File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py&quot;, line 1229, in _process_data
      data.reraise()
    File &quot;/usr/local/lib/python3.6/dist-packages/torch/_utils.py&quot;, line 425, in reraise
      raise self.exc_type(msg)
  AttributeError: Caught AttributeError in DataLoader worker process 0.
  Original Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py&quot;, line 287, in _worker_loop
      data = fetcher.fetch(index)
    File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py&quot;, line 44, in fetch
      data = [self.dataset[idx] for idx in possibly_batched_index]
    File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py&quot;, line 44, in &lt;listcomp&gt;
      data = [self.dataset[idx] for idx in possibly_batched_index]
    File &quot;/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataset.py&quot;, line 311, in __getitem__
      return self.dataset[self.indices[idx]]
    File &quot;main.py&quot;, line 64, in __getitem__
      img, target = self.transforms(img.target)
    File &quot;/usr/local/lib/python3.6/dist-packages/PIL/Image.py&quot;, line 546, in __getattr__
      raise AttributeError(name)
  AttributeError: target
  </code></pre>
  <p>I believe I have followed the tutorial completely, copying their code - I'm a bit unsure, therefore, why this error is arising. For a beginner who's trying to learn how to use ML in computer vision it's especially difficult to figure out what's going on here.</p>
  <p>I don't know if this is important, but I'm running Python3 on Ubuntu.</p>
  <p>Many thanks in advance for your help! :)</p>