• 函数作用
      torch.nn.MSELoss() 求predict和target之间的loss。
    • 代码示例
      单个求其loss:
    • crit = nn.MSELoss()
      # target = torch.Tensor(1)
      # target[0] = 10
      # res = torch.Tensor(1)
      # res[0] = 5
      # cost  = crit(res,target)#25
      # print(cost)
      target = torch.Tensor(2)
      target[0] = 10
      target[1] = 6
      res = torch.Tensor(2)
      res[0] = 5
      res[1] = 3
      cost  = crit(res,target)#(25+9)/2
      print(cost)

       

相关文章:

  • 2022-12-23
  • 2022-02-09
  • 2021-09-20
  • 2022-01-12
  • 2022-12-23
  • 2021-08-31
  • 2021-11-23
  • 2021-10-25
猜你喜欢
  • 2021-04-11
  • 2021-06-15
  • 2021-11-29
  • 2021-06-01
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案