What is the difference between permutationa and reshape? #544
Unanswered
Endtroducing1993
asked this question in
Q&A
Replies: 1 comment
-
Hi,
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Team,
Suppose we have a tensor called tensor_A of shape (3,4).
What is the difference between tensor.reshape(4,3) and tensor.permute(1,0)
I have seen by creating a random tensor that we obtain different results.
Can you please suggest, which one to use and where?
original tensor
tensor_original=torch.rand(size=(3,4))
tensor([[0.9829, 0.2585, 0.1642, 0.6212],
[0.6378, 0.7740, 0.8801, 0.7784],
[0.0042, 0.5443, 0.8029, 0.4538]])
rehshaped_tensor
tensor_reshape=tensor_original.reshape(4,3)
tensor([[0.9829, 0.2585, 0.1642],
[0.6212, 0.6378, 0.7740],
[0.8801, 0.7784, 0.0042],
[0.5443, 0.8029, 0.4538]])
permuted tensor
tensor_permuted=tensor_original.permute(1,0)
tensor([[0.9829, 0.6378, 0.0042],
[0.2585, 0.7740, 0.5443],
[0.1642, 0.8801, 0.8029],
[0.6212, 0.7784, 0.4538]])
Beta Was this translation helpful? Give feedback.
All reactions