-
Hello, I am new to pytorch so I do not have much idea about tensors. I tried creating a 6 dimensional tensor so as to understand how the dimension and shape command work. However, I noticed that the following tensor is returning some sort of error ten_6 = torch.tensor([[[[[[1,1],[1,1]],[[1,1],[1]],[[1,1],[1,1]],[[1,1],[2,2]]]]]])
print(ten_6)
print(ten_6.shape)
print(ten_6.ndim) ErrorMeanwhile this tensor is just fine ten_6 = torch.tensor([[[[[[1,1],[1,1]],[[1,1],[1,1]],[[1,1],[1,1]],[[1,1],[2,2]]]]]])
print(ten_6)
print(ten_6.shape)
print(ten_6.ndim) Can someone please help me understand this bit? Thank you.. |
Beta Was this translation helpful? Give feedback.
Answered by
matrx2000
Jun 11, 2024
Replies: 1 comment
-
Tensors need to have consistent dimensions at each level of nesting. In the provided list structure, all sub-lists at the same level must have the same number of elements. In your example: [
[
[
[
[
[1,1],[1,1]
],
[
[1,1],[1] #<-- error is here
],
[
[1,1],[1,1]
],
[
[1,1],[2,2]
]
]
]
]
] |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
kkdotpy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tensors need to have consistent dimensions at each level of nesting. In the provided list structure, all sub-lists at the same level must have the same number of elements. In your example: