Hi, i’m going to apply some kind of constraint to the output. However, the thresholds for each elements are different. I noticed that both torch.clamp and nn.HardTanh take scalars as argument. Are there any workaround for this?
Thanks!
Hi, i’m going to apply some kind of constraint to the output. However, the thresholds for each elements are different. I noticed that both torch.clamp and nn.HardTanh take scalars as argument. Are there any workaround for this?
Thanks!
torch.min may help
import torch as t
a = t.randn(4,3) # size : batch_size x element_num
b = t.randn(1,3) # constrain for each element
results = t.min(a,b)