__new__() missing 1 required positional argument: 'aux_logits'

I was fine-tuning inception_v3 from torchvision, but when I use DataParallel I met a TypeError:__new__() missing 1 required positional argument: 'aux_logits' , here are my code:

model = inception_v3(pretrained=True)
class_num = 8
channel_in = model.fc.in_features
model.AuxLogits.fc = nn.Linear(768, class_num)
model.fc = nn.Sequential(nn.Dropout(p=0.2),
                         nn.Linear(channel_in, class_num))

optimizer = torch.optim.Adam(model.parameters(), lr=lr)
loss_fn = nn.CrossEntropyLoss()

model = nn.DataParallel(model)
model.aux_logits = True
model = model.cuda()
loss_fn = loss_fn.cuda()
outputs, aux_outputs = model(batch_x)
loss1 = loss_fn(outputs, batch_y)
loss2 = loss_fn(aux_outputs, batch_y)
loss = loss1 + 0.4*loss2

could anyone tell me how to solve this problem?Thank you!

1 Like

Hello, I am having the same issue. Did you figure out a workaround for this other than disabling the aux_logits output in the model?