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)

相关文章:

  • 2021-10-08
  • 2021-05-25
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-11
  • 2021-11-02
  • 2021-07-14
  • 2021-08-30
  • 2022-12-23
  • 2021-07-06
相关资源
相似解决方案