7

while trying to finetune inception_V3 for my own dataset by changing the last fc layer like

last_layer =nn.Linear(n_inputs, len(classes))
inception_v3.fc = last_layer

after that when I train it got this error on this position

    # on training loop
    output = inception_v3(data)
    # calculate the batch loss
    loss = criterion(output, target)

Error is

 AttributeError: 'tuple' object has no attribute 'log_softmax'

2 Answers 2

14

This is a well known problem.

Try one the following solutions:

  1. disable aux_logits when the model is created here by also passing aux_logits=False to the inception_v3 function.

  2. edit your train function to accept and unpack the returned tuple to be something like: output, aux = model(input_var)

Check the following link for more info.

Sign up to request clarification or add additional context in comments.

1 Comment

solved by doing inception_v3 = models.inception_v3(pretrained=True) inception_v3.aux_logits=False
4

This problem seams to me like instead you define F:

import torch.nn.functional as F

You in accident have set F to some tuple

F=(1,2)

And then when you call F.log_softmax you get exactly this error.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.