Ermm, I can’t possible call A.backward(), it is not a scalar. To be exact, my loss calculation is as such
distance_target = torch.sum((feature_adversarial - feature_target.clone()) **2) distance_identity = torch.sum((feature_adversarial - feature_identity.clone()) ** 2) loss = distance_target + 2*distance_identity loss.backward()
features are vector of size (1, 512).
feature_target and feature_identity are outputs of my model as well, but they are fixed thereafter.
The only part that changes is feature_adversarial.
Are you suggesting that I instantiate two separate instance of the same models?