clamp的意思就是clip,>a的变成a,小于b的变成b,其他的不变
此处,x跟r是一样的,可能写错了。
使用pytorch写的关于权重的伪代码为
n = 256
x = torch.rand([4,5,6,7]) - 0.5
b = x.max()
w = torch.rand([4,5,6,7]) - 0.5
a = w.min()
b = w.max()
s = (b - a)/(n-1)
q = torch.round((w - a)/s)*s+a
【1】中国芯片开源社区