typeError: cross_entropy_loss() argument input(position 1) must be a tensor, not googlenetOutputs

Hi everyone,

I faced the above error when I tried to use torchvision.models.googlenet as follow:
model=models.googlenet(num_classes=args.num_class).cuda()

If someone has an idea about how I can solve that, I will be appreciable.

Thanks

GoogLeNet outputs an object in training mode called GoogLeNetOutputs which contains .logits, .aux_logits1, and .aux_logits2.
You would thus have to index the desired attribute to calculate your loss instead of passing the object directly to your criterion.

Many thanks
it’s solved :blush: