Hi all,
I am updating my model in 2 steps: 1) variable optimization; 2) projection to the optimization constraints. I found the _version of the tensor changed after the projection. So the step 1) optimization on the wrong tensor version. The codes are shown below. Is it possible to keep the tensor _version not changed? Thanks~
optimizer = torch.optim.SGD([x], lr=0.3)
For i in range(iteration):
    optimizer.zero_grad()
    probs = myfunc(x)
    probs.backward()
    optimizer.step() # optimization on x._version = 0

    x = projection(x) # _version number will be increased here