Sorry, I know questions of this sort have been asked a lot, but I still don't understand the behavior of autograd.
A simple example is below:
ce_loss=torch.nn.BCELoss()
par=torch.randn((1,n),requires_grad=True)
act=torch.nn.Sigmoid()
y_hat=[]
for obs in data:
y_hat.append(act(par@obs))
loss=ce_loss(torch.tensor(y_hat,requires_grad=True),y)
loss.backward()
After applying backward, the grad of par remains None (although it is a leaf node with requires_grad=True).
Any tips?