pytorch / pytorch/tutorials

[BUG] - <title> TypeError when using len(train_dataloader.dataset) in Quickstart PyTorch tutorial

Open
#3,226 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug core intro
Dominant language
Python
Stars
9.3k
Forks
4.4k
Avg merge
1d 21h
Merged PRs (30d)
4

Description

Add Link

https://pytorch.org/tutorials/beginner/basics/quickstart_tutorial.html

Describe the bug

When using len(train_dataloader.dataset) to get the dataset size in the Google Colab notebook from Quickstart PyTorch, I encountered the following error:

TypeError: 'FashionMNIST' object is not callable

I think we can use another way to take the size we need:

train_dataloader.dataset.data.shape[0]
```

### Describe your environment

Google Colab
Torch version: 2.5.1+cu121

cc @subramen @albanD @jbschlosser

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Quickstart PyTorch tutorial and its linked Google Colab notebook, then locate the use of len(train_dataloader.dataset) that produces the FashionMNIST TypeError. Verify the corrected dataset-size expression in Colab and confirm the tutorial runs without that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.