Hi all. Thanks for your help in advance.

I am trying to compute the gradient of log probability with respect to the data X.

The probability is computed through sigmoid of the output of some neural networks.

Here, I use the network “prob_ScoreNet” that I implemented and freeze the model parameters.

Following is the code that I am trying to run.

for param in prob_ScoreNet.parameters():

param.requires_grad = False

X = torch.tensor(X, requires_grad = True)

class_prob = prob_ScoreNet(X, time_step.unsqueeze(0))

function = torch.log(F.sigmoid(class_prob)+1e-10)

gradients = torch.autograd.grad(function, X)[0]

The data X is of size [100000, 8] and keep facing the memory allocation problem.

I don’t know how to fix this, and not sure if the above code is correct.