Skip to content

Update Intro YouTube Training with PyTorch tutorial — v2 transforms, super(), formatting #3858

@svekars

Description

@svekars

Description

The Training with PyTorch tutorial uses deprecated torchvision transforms, Python 2-style super(), and old string formatting throughout.

Changes needed

Deprecated APIs

  • transforms.ToTensor()v2.ToImage() + v2.ToDtype(torch.float32, scale=True): ToTensor() is deprecated since torchvision 0.18 and lives in torchvision.transforms._deprecated.py. Update Compose and Normalize to v2 namespace as well.

Outdated patterns

  • Python 2-style super(GarmentClassifier, self).__init__()super().__init__()
  • .format() → f-strings (9 instances):
    • 'Training set has {} instances'.format(...)
    • 'Validation set has {} instances'.format(...)
    • 'Total loss for this batch: {}'.format(...)
    • ' batch {} loss: {}'.format(...)
    • 'runs/fashion_trainer_{}'.format(timestamp)
    • 'EPOCH {}:'.format(...)
    • 'LOSS train {} valid {}'.format(...)
    • 'model_{}_{}'.format(...)

Files

cc @subramen

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions