Skip to content Skip to sidebar Skip to footer

How To Use Pytorch To Calculate Partial Derivatives?

I want to use PyTorch to get the partial derivatives between output and input. Suppose I have a function Y = 5*x1^4 + 3*x2^3 + 7*x1^2 + 9*x2 - 5, and I train a network to replace t

Solution 1:

A neural network is a universal function approximator. What that means is, that, for enough computational resources, training time, nodes, etc., you can approximateany function. Without any further information on how you trained your network in the first example, I would suspect that your network simply does not fit properly to the underlying function, meaning that the internal representation of your network actually models a different function!

For the second code snippet, autmatic differentiation does give you the exact partial derivative. It does so via a different method, see another one of my answers on SO, on the topic of AutoDiff/Autograd specifically.

Post a Comment for "How To Use Pytorch To Calculate Partial Derivatives?"