Hello,
I’m a beginner of pytorch.
I’m trying to classicification of VGG using CIFAR10.
The last of course, I’m making the train loop as belows,
But I got the typeerror but I don’t what is wrong.
Please help me.
----(code)
for epoch in range(100):
for data, label in train_loader:
optim.zero_grad()
preds = model(data.to(device))
loss = nn.CrossEntropyLoss()(grads, label.to(device))
loss.backward()
optim.step()
if epoch==0 or epoch%10==9:
print(f"epoch{epoch+1} loss:{loss.item()}")
---------(error)
TypeError Traceback (most recent call last)
in
7
8 for epoch in range(100):
----> 9 for data, label in train_loader:
10 optim.zero_grad()
11 preds = model(data.to(device))
4 frames
/usr/local/lib/python3.8/dist-packages/torchvision/datasets/cifar.py in getitem(self, index)
116
117 if self.transform is not None:
→ 118 img = self.transform(img)
119
120 if self.target_transform is not None:
TypeError: ‘module’ object is not callable