Skip to content

Random error #508

Answered by Surya-Abhinai
Aditi4AI asked this question in Q&A
Jun 29, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

First, you are creating a tensor A of size 3x3 using the torch.rand function. By default, torch.rand generates a tensor with random values between 0 and 1 of the torch.float32 data type.

Next, you are converting the tensor A to the torch.int32 data type using the type method and assign it to a new tensor B. This conversion truncates the decimal parts of the values in A, rounding them down to the nearest integer.

As a result, the output tensor B will contain integer values. In this case, since the original tensor A was generated using torch.rand, which produces random values between 0 and 1, when converting to integers, all values will be rounded down to 0. Therefore, the output tensor B w…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Aditi4AI
Comment options

Answer selected by Aditi4AI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants