Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'
like image 880
Israel-abebe Avatar asked Nov 26 '18 07:11

Israel-abebe


1 Answers

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.

like image 133
kHarshit Avatar answered Oct 02 '22 01:10

kHarshit