autograd

How to make formula differentiable for a binary classifier in PyTorch

How to make formula differentiable for a binary classifier in PyTorch Question: I am trying to create a custom loss function for a binary classifier case. I need the binary predictions as an input to the function. However, I am getting to a point where I am unable to create a the process differentiable. I …

Total answers: 1

Custom torch.nn.Module not learning, even though grad_fn=MmBackward

Custom torch.nn.Module not learning, even though grad_fn=MmBackward Question: I am training a model to predict pose using a custom Pytorch model. However, V1 below never learns (params don’t change). The output is connected to the backdrop graph and grad_fn=MmBackward. I can’t understand why V1 isn’t learning but V2 is? V1 class cam_pose_transform_V1(torch.nn.Module): def __init__(self): super(cam_pose_transform, …

Total answers: 1

Evaluating pytorch models: `with torch.no_grad` vs `model.eval()`

Evaluating pytorch models: `with torch.no_grad` vs `model.eval()` Question: When I want to evaluate the performance of my model on the validation set, is it preferred to use with torch.no_grad: or model.eval()? Asked By: Tom Hale || Source Answers: TL;DR: Use both. They do different things, and have different scopes. with torch.no_grad – disables tracking of …

Total answers: 3