Outputs of inception_v3 has no attribute 'data'

model = models.inception_v3(pretrained=True)
for data in dataloders[‘val’]:
inputs, labels = data
inputs, labels = Variable(inputs), Variable(labels)
outputs = model(inputs)
_, preds = torch.max(outputs.data, 1)

Then, from the last line, I got the AttributeError: ‘tuple’ object has no attribute ‘data’, however, when I was using pretrained resnet or densetnet, no errors like this.

add a print and figure out what outputs is. Please dont blindly copy-paste code from one network to another and expect it to work. some networks are different.

The inception_v3 model has Auxillary classifiers which will also give you outputs when you run model(inputs). Thus the outputs variable is a tuple rather than a tensor. It is always a good idea to look into the model source code before running it.

outputs,aux_output = model(inputs)

I have used this for the inception v3 . my code ran perfectly for training for when it came to validation it shows " too many values to unpack "