unexpected error in pytorch backward

在写模型训练的时候遇到奇怪的报错:

1
RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed. Specify retain_graph=True when calling backward the first time.
Read more