Pytorch parameter initialization

When I initialize the model parameters, I find that the methods of the tensor object do not work, I hope the experts will help me

I don’t know if your IDE is just claiming this is an error, but in any case you shouldn’t use the .data attribute anymore as it can have unwanted side effects.
Wrap the code into a with torch.no_grad() guard and it should work:

model = nn.Linear(10, 10)
print(model.weight.mean(), model.weight.std())
# > tensor(0.0017, grad_fn=<MeanBackward0>) tensor(0.1861, grad_fn=<StdBackward0>)

with torch.no_grad():
    model.weight.normal_(0, 1)

print(model.weight.mean(), model.weight.std())
# > tensor(0.0941, grad_fn=<MeanBackward0>) tensor(1.0250, grad_fn=<StdBackward0>)