본문 바로가기
Tech Development/Computer Vision (PyTorch)

PyTorch: Results & Trouble Shooting

by JK from Korea 2023. 5. 15.

<PyTorch: Results & Trouble Shooting> 

 

Date: 2023.05.14               

 

* The PyTorch series will mainly touch on the problem I faced. For actual code, check out my github repository.

 

[Results of Multiclass Classification]

The results of the “make_blobs” classification problem is as the following.

 

[Train Size = 960, Test Size = 240]

 

[Results for 1000 Epochs (repeats)]

 

Call it a day.

 

[Trouble Shooting]

While training the model, I ran into some fundamental PyTorch issues.

 

[Original Code (partial code of training loop)]

 

[Error Code &ldquo;Runtime&rdquo;]

 

It would’ve taken a long time to fix this data type issue. From the Runtime Error message I could tell that the input value for the loss function, which in this case was Cross Entropy Loss, is not compatible with the build-in type. Referencing to the PyTorch documentation I found the following.

 

[Example code provided on the official documentation]

 

As you can see, the “target” input for the cross entropy loss function is type “long.” Thus, the y data should be data type long the for the loss function to work.

 

[y -> LongTensor]

728x90
반응형

댓글