torch.clamp() does not work properly
The environment I used was google colaboratory
I ran torch.clamp() according to the official documentation
https://pytorch.org/docs/master/generated/torch.clamp.html
working program
print(torch.__version__)
a = torch.randn(4)
print(a)
torch.clamp(a, min=-0.5, max=0.5)
print(a)
The results obtained
1.5.1+cu101
tensor([-0.8323, -0.0443, 0.4641, 0.0824])
tensor([-0.8323, -0.0443, 0.4641, 0.0824])
If it works like the document, the original result is tensor([-0.5, -0.0443, 0.4641, 0.0824])
What’s wrong with that?
Is this a bug?
I want to set constraints on weight parameters like keras.constraints
I can’t do it because torch.clamp() doesn’t work properly.