I thought such a combination should throw an error. I can’t imagine why anyone would want to compute higher derivates but then forget the graph. Wouldn’t the screw up the computation of higher derivatives by freeing the graph to early?
Why doesn’t that throw an error?
- retain_graph ( bool , optional ) – If
False, the graph used to compute the grad will be freed. Note that in nearly all cases setting this option to
Trueis not needed and often can be worked around in a much more efficient way. Defaults to the value of
- create_graph ( bool , optional ) – If
True, graph of the derivative will be constructed, allowing to compute higher order derivative products. Defaults to