Trying to understand modules/variables/autograd a bit better, so I made a a loss function that penalizes a point by 1 if it is 0.5 away from the target and 0 otherwise. I used the following forward
def forward(self, input_var, target_var):
    D = torch.norm(input_var - target_var)
    return sum(D > 0.5)

But I get the error RuntimeError: there are no graph nodes that require computing gradients when I run backward() on this loss. I don’t seem to release any data from variables or use numpy arrays. So I think I’m misunderstanding something fundamental about autograd. Any help would be appreciated. Thanks