问题
Title says it all. Is there a convenient function in pytorch that can do something like np.trapz(y, x)
(integrating over the the points in x
and y
via trapezoidal rule)?
回答1:
There is no built-in tool for that, but it should not be difficult to implement it yourself, especially using the numpy code as a guideline.
回答2:
Since pytorch version 1.2 a native trapz function has been introduced.
来源:https://stackoverflow.com/questions/55605577/how-to-do-numerical-integration-with-pytorch-similar-to-numpys-trapz-function