Hi,
I am using torch.nn.BCELoss() and F.binary_cross_entropy_with_logits, but loss.grad() is always constant 1.
Do you know why this happens and how to solve it?
Thanks!
        optimizer.zero_grad()
        A_pred, z = model(features, adj_norm)

        weight_tensor = torch.tensor(weight_tensor, dtype=torch.float).cuda()

        criterion = torch.nn.BCELoss(weight=weight_tensor)
        log_lik = norm*criterion(A_pred.view(-1), adj_label.to_dense().view(-1))
        loss = log_lik 
        loss.retain_grad()
        loss.backward()
        print(loss.grad)
        optimizer.step()