I want to use the inception_v3 framework that comes with torchversion ,but  it nake a mistake.
model.fc = nn.Sequential(nn.Linear(2048,512),
nn.ReLU(),
nn.Dropout(0.2),
nn.Linear(512,5),
nn.LogSoftmax(dim=1))
for epoch in range(epochs):
for inputs,labels in train_loader:
inputs,labels = inputs.to(device),labels.to(device)
optimizer.zero_grad()
out = model(inputs)
loss = criterion(out,labels)
loss.backward()
optimizer.step()
running_loss +=loss.item()
steps +=1
    if (steps+1)%5 == 0:
        test_loss = 0
        accuracy = 0
        model.eval()
        with torch.no_grad():
            for inputs,labels in test_loader:
                inputs, labels = inputs.to(device), labels.to(device)
                out2 = model(inputs)
                batch_loss = criterion(out2,labels)
                test_loss +=batch_loss.item()

                ps = torch.exp(out2)
                top_pred,top_class = ps.topk(1,dim=1)
                equals = top_class == labels.view(*top_class.shape)
                accuracy += torch.mean(equals.type(torch.FloatTensor)).item()

        train_losses.append(running_loss/len(train_loader))
        test_losses.append(test_loss/len(test_loader))

        print(f"Epoch {epoch+1}/{epochs}"
              f"Train loss: {running_loss/5:.3f}",
              f"Test loss: {test_loss/len(test_loader):.3f} "
              f"Test accuracy: {accuracy/len(test_loader):.3f}")
        running_loss = 0
        model.train()

Traceback (most recent call last):
File “F:/csdncollection/train.py”, line 81, in 
loss = criterion(out,labels)
File “D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “D:\Anaconda3\lib\site-packages\torch\nn\modules\loss.py”, line 209, in forward
return F.nll_loss(input, target, weight=self.weight, ignore_index=self.ignore_index, reduction=self.reduction)
File “D:\Anaconda3\lib\site-packages\torch\nn\functional.py”, line 1863, in nll_loss
dim = input.dim()
AttributeError: ‘tuple’ object has no attribute ‘dim’
I hope someone could help me .