우당탕탕 도비의 코딩로그

[Pytorch] IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1) 해결하기 본문

ERROR_SOLUTION/PYTORCH

[Pytorch] IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1) 해결하기

dobbie 2021. 2. 26. 21:52
반응형
더보기

 

 

nn.CosineEmbeddingLoss(x_1, x_2, y) 를 불러올때 batch_size가 1인 경우에는

각각 x_1, x_2, y tensor들의 shape 을 정의해주니 해결되었다.

 

나의 경우에는 tensor의 shape이 [1,64] 이어서 

x_1.reshape(1,64)
x_2.reshape(1,64)
y.reshape(1,64)

 

로 각각 정의해주었다.

 

 

 

반응형
Comments