Hi, I am trying to use my customized embedding loss for learning.
However, I have been getting the error below:
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
Below is my code for the loss function:
def disc_loss(output,num, x=None,y=None):
    if pred == True:
        #pdist = nn.PairwiseDistance(p=2)
        #loss = pdist(x,y).sum()
        num = x.size(1)
        loss = torch.sqrt(torch.sum((x-y)**2))
    return loss

x and y in the function are the embedding that I got from intermediate conv layer.
I keep getting the error message during .backward() function, but I am not sure what is wrong with my implementation. Can somebody help me with this?
Thank you!