How to do numerical integration with pytorch similar to numpy's trapz function?

ε祈祈猫儿з 提交于 2020-07-07 17:37:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!