Hi,
I have difficulties to understand why this code does not throw error
model = torch.nn.Linear(512,2)

opt = torch.optim.SGD(model.parameters(), lr=0.1)

inputs = torch.rand((32,512))
outputs = torch.rand((32,2))

opt.zero_grad()
pred = model(inputs)
pred[:,1] = torch.sigmoid(pred[:,1])
loss = torch.nn.functional.mse_loss(pred, outputs)
loss.backward()
opt.step()

But if I replace torch.sigmoid by torch.nn.functional.relu it throws RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation.
What is the hidden reason explaining the difference between the two activation functions ?
Thank you very much