Skip to content

Update deprecated APIs in introyt1_tutorial#3812

Open
svekars wants to merge 1 commit intomainfrom
update-introyt
Open

Update deprecated APIs in introyt1_tutorial#3812
svekars wants to merge 1 commit intomainfrom
update-introyt

Conversation

@svekars
Copy link
Copy Markdown
Contributor

@svekars svekars commented Apr 1, 2026

This PR modernizes the Introduction to PyTorch tutorial (introyt1_tutorial.py) by replacing deprecated APIs with their current equivalents.

Deprecated API replacements:

  • torch.det() → torch.linalg.det() (deprecated alias since PyTorch 1.9)
  • torch.svd() → torch.linalg.svd() (deprecated since PyTorch 1.9, will be removed in a future release)
  • transforms.ToTensor() → v2.ToImage() + v2.ToDtype(torch.float32, scale=True) (the entire non-v2 transforms module is unmaintained; ToTensor lives in torchvision.transforms.v2._deprecated)
  • import torchvision.transforms as transforms → from torchvision.transforms import v2

Python style modernization:

  • super(ClassName, self).init() → super().init() (Python 3 style, PEP 3135)
  • '%d' % value string formatting → f-strings

Documentation updates:

  • Added .. note:: about the video being recorded with an older PyTorch version
  • Added .. note:: about torch.linalg as the recommended linear algebra API
  • Updated transforms explanation text to describe v2.ToImage() and v2.ToDtype() instead of ToTensor()
  • Updated inline code snippet for calculating dataset mean/std to use v2 transforms
  • Added link to torchvision.transforms.v2 docs

cc @albanD @jbschlosser

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 1, 2026

🔗 Helpful Links

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

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

✅ No Failures

As of commit 470cfad with merge base f79c3d9 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@meta-cla meta-cla bot added the cla signed label Apr 1, 2026
@svekars svekars added the core Tutorials of any level of difficulty related to the core pytorch functionality label Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed core Tutorials of any level of difficulty related to the core pytorch functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant