Post

TorchVision: My First Pull Request

A Description of My First PR in Torchvision.

TorchVision: My First Pull Request

Feature/Bug Requested

The classes attribute of EMNIST dataset does not take into account the split argument. From the original EMNIST dataset: https://www.nist.gov/itl/products-and-services/emnist-dataset

Issue Details

Understanding the Problem

The existing code doesn’t consider the splits parameter that is passed to the dataset. This is because the EMNIST class inherits the default MNIST class and doesn’t set the classes attribute appropriately.

Solution

I knew that overriding the classes attribute should do the job. From the details provided in the issue and from the link, I was able to create a dictionary that maps the splits into classes. I was a not confident with my solution initially, but then I tried to use it locally with my changes in place and gained confidence over my changes. Finally, I overrode the classes attribute to get the expected behavior.

Changes Made by Me

Key Learnings

  1. Always create a branch for developing a feature or fixing a bug. Working on the master branch of a fork will be a mess as other features can get merged to the master branch of the original repo and syncing will be difficult.
  2. Don’t be afraid to commit mistakes or submit dumb solutions. Not all solutions are great. Maintainers are there to help and will review the changes and suggest better approaches if any.
  3. Don’t forget to lint the code before pushing a change. I had to submit a few times to get the linting part correct.

I know the changes are not much, but I feel thrilled that I have a PR merged in torchvision repo. Thanks for reading. I encourage you to try to contribute to any Open Source project. I can assure it will be a great learning experience.