Skip to content

Update deprecated APIs in introyt1_tutorial#3812

Open
svekars wants to merge 2 commits into
mainfrom
update-introyt
Open

Update deprecated APIs in introyt1_tutorial#3812
svekars wants to merge 2 commits into
mainfrom
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 d48d276 with merge base 05c08f2 (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
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 20, 2026

Hi @svekars!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

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