It's my first time to use stack overflow. Thanks for your help! Recently, I'm learning Deep-Learning with Pytorch. When I finished the DataSet and DataLoader, I got some trouble in writing train function. It show me that:
<ipython-input-16-e211160f5ce8> in <module>()
5 total = 0
6 for id, (inputs, labels) in enumerate(train_loader):
----> 7 inputs, labels = inputs.cuda(), labels.cuda()
8 optimizer.zero_grad()
9 outputs = net(inputs)
AttributeError: 'tuple' object has no attribute 'cuda'
My code is here:
for id, (inputs, labels) in enumerate(train_loader):
inputs, labels = inputs.cuda(), labels.cuda()
optimizer.zero_grad()
outputs = net(inputs)
loss = self.criterion(outputs, labels)
loss.backward()
optimizer.step()
The Dataloader return image and labels, the image's type is numpy.array and the labels' type is tuple. I can not do anything to the parameters inputs and labels. I don't find answer in Google. Thanks for help and endure my English and code.
For more details: My dataset is Stanford Cars, and I use it to achieve image classification. It just a simple code, I don't know what's worry with it. Or you can give me some advice to learn Pytorch, Thanks:) torch 1.5.0+cu101 torchvision 0.6.0+cu101