in utils/pytorch_util.py [0:0]
def fanin_init(tensor, scale=1):
size = tensor.size()
if len(size) == 2:
fan_in = size[0]
elif len(size) > 2:
fan_in = np.prod(size[1:])
else:
raise Exception("Shape must be have dimension at least 2.")
bound = scale / np.sqrt(fan_in)
return tensor.data.uniform_(-bound, bound)