torch.randn
时间: 2023-09-22 10:11:27 浏览: 84
torch.randn is a function in the PyTorch library that generates a tensor with random values drawn from a standard normal distribution (mean=0, standard deviation=1). It takes in a size argument which specifies the shape of the output tensor.
For example, the following code generates a tensor of size (3, 4) with random values:
```
import torch
x = torch.randn(3, 4)
print(x)
```
Output:
```
tensor([[-0.5828, 0.2436, 0.1174, -0.8029],
[ 0.3970, -0.5141, -0.1323, 0.5626],
[-0.4569, -0.0591, 0.6372, 0.4185]])
```
阅读全文