We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Medium
Framework
Compute Gradient
Compute the gradient of f(x) = x^3 + 2x^2 + x at a given point using automatic differentiation.
The analytical derivative is f'(x) = 3x^2 + 4x + 1.
Input: A scalar value x.
Output: A scalar tensor equal to f'(x).
API Reference:
-
PyTorch:
torch.autograd.gradorbackward()withrequires_grad=True -
JAX:
jax.grad(f)(x)
Nothing accepted yet. When a submission passes, the code that passed shows up
here, one entry per mode.
Stuck?
PyTorch reference solution
Sign in to attempt this problem and reveal the reference solution.