pytorch的HingeEmbeddingLoss 有先后順序


L1Loss  MSELoss 都沒問題,但是 HingeEmbeddingLoss 卻總報錯 說不能求梯度

 

#criterion = nn.MSELoss()
#criterion = nn.L1Loss()
criterion = nn.HingeEmbeddingLoss()

 

https://pytorch.org/docs/stable/generated/torch.nn.HingeEmbeddingLoss.html#torch.nn.HingeEmbeddingLoss

 

發現 Hinge損失函數還是區分了 

  • Input: (*)() where *∗ means, any number of dimensions. The sum operation operates over all the elements.

  • Target: (*)() , same shape as the input

  • Output: scalar. If reduction is 'none', then same shape as the input

 

 保證模型輸出的變量在第一個就可以了,第二個是Label/Target

      loss =criterion(out, data.y)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM