报错:

RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.

 

 修改:

model.module.optimizer_G.zero_grad()
loss_G.backward()
model.module.optimizer_G.step()
为:
model.module.optimizer_G.zero_grad()
loss_G.backward(retain_graph=True)
model.module.optimizer_G.step()
问题解决。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-08-13
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2021-07-18
  • 2021-08-25
  • 2022-02-26
相关资源
相似解决方案