Skip to content

Update introyt model tutorial APIs#3895

Open
Vasanthadithya-mundrathi wants to merge 1 commit into
pytorch:mainfrom
Vasanthadithya-mundrathi:fix/introyt-model-apis
Open

Update introyt model tutorial APIs#3895
Vasanthadithya-mundrathi wants to merge 1 commit into
pytorch:mainfrom
Vasanthadithya-mundrathi:fix/introyt-model-apis

Conversation

@Vasanthadithya-mundrathi
Copy link
Copy Markdown

Fixes #3856

Description

Updates the Building Models tutorial to use the current PyTorch API style:

  • specifies dim=1 for the TinyModel softmax layer
  • replaces Python 2-style super(...) calls with super().__init__()

Verification

  • python3 -m py_compile beginner_source/introyt/modelsyt_tutorial.py
  • MPLBACKEND=Agg /tmp/docathon-torch-venv/bin/python beginner_source/introyt/modelsyt_tutorial.py

Checklist

  • The issue that is being fixed is referred in the description
  • Only one issue is addressed in this pull request
  • Labels from the issue that this PR is fixing are added to this pull request
  • No unnecessary issues are included into this pull request.

cc @subramen

Copilot AI review requested due to automatic review settings May 12, 2026 17:43
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 12, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3895

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit 489b8a8 with merge base 046a3f3 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Building Models with PyTorch Intro YouTube tutorial code to align with current PyTorch/Python best practices and remove a Softmax deprecation warning, addressing Issue #3856.

Changes:

  • Specify the Softmax dimension explicitly in TinyModel via torch.nn.Softmax(dim=1).
  • Modernize module initialization by replacing Python 2-style super(Class, self).__init__() with super().__init__() in TinyModel, LeNet, and LSTMTagger.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@svekars
Copy link
Copy Markdown
Contributor

svekars commented May 12, 2026

@claude

@claude
Copy link
Copy Markdown

claude Bot commented May 12, 2026

Claude finished @svekars's task in 1m 4s —— View job


Review of PR #3895

  • Gather context and review changes
  • Check code correctness
  • Post review feedback

LGTM — this is a clean, minimal fix that addresses exactly what issue #3856 reported.

Changes look correct:

  1. torch.nn.Softmax(dim=1) (modelsyt_tutorial.py:56) — Good. Softmax without an explicit dim has been deprecated since PyTorch 1.0 and raises a warning at runtime. dim=1 is correct here since TinyModel expects batch input of shape (batch, 10) from Linear(200, 10).

  2. super().__init__() (lines 51, 153, 252) — Straightforward modernization. Python 3-style super() is preferred and equivalent in all single-inheritance cases like these.

  3. No other instances of super(ClassName, self) or bare Softmax() remain in the file.

No issues found. The changes are minimal, correct, and well-scoped.


@Vasanthadithya-mundrathi
Copy link
Copy Markdown
Author

CLA is signed now, and issue #3856 is assigned to me. Could a maintainer add the issue labels (docathon-2026, intro, easy) to this PR and approve the first-time contributor workflows when convenient?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Intro YouTube Building Models tutorial — Softmax dim, super() style

3 participants