Error after installing pytorch

Ive installed pytorch version below and tried running a piece of code which is producing the below error. Please help !!

Error log when I ran the code below:
File "D:\DREAM\pytorch\mycode\dataloader_test_1.py", line 15, in <module> transforms.toTensor(), AttributeError: module 'torchvision.transforms' has no attribute toTensor

Code used :
import torch

import torchvision

import torchvision.transforms as transforms

import torch.nn as nn

from torch.utils.data import DataLoader

FYI :
import torch torch.__version__
1.13.1+cu116

You have a typo and transforms.ToTensor() should work (note the capital T).

1 Like