Thank you for your detailed answer!



 ptrblck:

Could you explain, why label_A = make_variable(src_label.squeeze_()) is needed?



I originally wanted to use squeeze_ to convert the label into a one-dimensional tensor, but now I find that this is not necessary. So I removed squeeze_ and did not report the above error again.This is the label_A that I printed after removing squeeze_. Can it be used directly without the need to transform the form?

But I received the following warning:
微信图片_202006301219001883×79 7.93 KB
What caused this?




 ptrblck:

Yes, you can simply pass tensors to the model.
If your input does not require gradients (which is the usual case), then just remove the Variable(tensor) call completely.



After I removed Variables, I encountered this error when entering the network. How do I deal with it?

preds = classifier(encoder(images))

微信图片_202006301227081470×429 30.6 KB