L1Loss MSELoss 都沒問題,但是 HingeEmbeddingLoss 卻總報錯 說不能求梯度
#criterion = nn.MSELoss()
#criterion = nn.L1Loss()
criterion = 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)