import torch
w = torch.empty(3, 5)
print(w)
print(nn.init.constant_(w, 0.3))
print(w)
print(nn.init.constant_(w, 2.3))
# -------- output -------
tensor([[8.1276e-36, 0.0000e+00, 2.3694e-38, 1.2598e-01, 3.0000e-01],
[3.0000e-01, 3.0000e-01, 3.0000e-01, 3.0000e-01, 3.0000e-01],
[3.0000e-01, 3.0000e-01, 3.0000e-01, 3.0000e-01, 3.0000e-01]])
tensor([[0.3000, 0.3000, 0.3000, 0.3000, 0.3000],
[0.3000, 0.3000, 0.3000, 0.3000, 0.3000],
[0.3000, 0.3000, 0.3000, 0.3000, 0.3000]])
tensor([[0.3000, 0.3000, 0.3000, 0.3000, 0.3000],
[0.3000, 0.3000, 0.3000, 0.3000, 0.3000],
[0.3000, 0.3000, 0.3000, 0.3000, 0.3000]])
tensor([[2.3000, 2.3000, 2.3000, 2.3000, 2.3000],
[2.3000, 2.3000, 2.3000, 2.3000, 2.3000],
[2.3000, 2.3000, 2.3000, 2.3000, 2.3000]])
torch.nn.init.constant_(tensor, value)
最新推荐文章于 2023-12-20 04:15:00 发布