Explain the two arguements in torch.randn()?

Hello,

Please can someone explain the two arguements in torch.randn(). Refer to the example is below:

a = torch.randn(1, 3)
a

tensor([[0.0146, 0.4258, 0.2211]])

Hey,

The arguments your randn function specify the shape of the Tensor you want to populate with random values.

So, (1,3) would be Tensor shaped as such -
[
[a, b, c ]
]

Similarly, a tensor with shape (2,3) would be -
[
[a, b, c],
[x, y, z]
]

And a tensor with a shape (1,2) -
[
[a, b]
]

2 Likes

Thank you @aniketj97

They are the dimensions of the tensor. rows x columns

1 Like
a = torch.randn(Rows, Columns)

The first argument defines the number of rows and the second defines the number of columns in your tensor.

1 Like

Row, Column. torch.randn() generate random numbers

1 Like