x.norm()函数:
http://www.pythonheidong.com/blog/article/170104/

torch.autograd.grad函数:
计算张量的梯度函数,返回值的shape和函数输入的值的shape一致
outputs:函数的输出

inputs:函数的输入 grad_outputs:权重,下面代码是和输出大小一致的全1张量
1 disc_interpolates = netD(interpolates)
2 gradients = torch.autograd.grad(outputs=disc_interpolates, inputs=interpolates,
3                           grad_outputs=torch.ones(disc_interpolates.size()).to(device),
4                           create_graph=True, retain_graph=True, only_inputs=True)[0]

相关文章:

  • 2021-10-31
  • 2021-09-23
  • 2022-12-23
  • 2022-01-22
  • 2023-02-03
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-20
  • 2021-12-12
  • 2021-09-28
  • 2021-11-19
  • 2021-07-10
  • 2022-01-30
  • 2021-11-13
相关资源
相似解决方案