Skip to content

mnist example contains bad practices leading to wrongful results #623

Open

Description

@kirk86

In the mnist example there should be explicit comments about the default nature of the F.nll_loss which is to average the results over the mini-batch. The other thing that can lead to errors is the len(train_loader.dataset) even though that returns the number of samples in the train dataset if someone was to create a split of train data into train/valid using SubsetRandomSampler then calling again len(train_loader.dataset) will still return you the full number of samples in the train set (which is wrong) without reflecting the correct number of samples since the train set now contains X% less samples which have been kept as validation set.

Activity

  1. changed the title [-]mnist examples contains bad practices leading to wrongful results[/-] [+]mnist example contains bad practices leading to wrongful results[/+] on Aug 27, 2019
  2. msaroufim commented on Mar 9, 2022

    @msaroufim
    Contributor

    Hi @kirk86 would you like to make a PR for this?

  3. sanshi00000030 commented on Oct 21, 2025

    @sanshi00000030

    Hi, I'm a new contributor and would like to try fixing this issue. I have already prepared a fix and will submit a pull request for it shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions