Two Parameters
A curve predicts a * x² + b * x for every element of x, and its loss is the mean of the squared differences from y. Return the gradient of the loss with respect to a and to b, at the values given: [d loss / d a, d loss / d b].
Example 1
x [1.0,2.0]
y [0.0,0.0]
a 1.0
b 0.0
returns [17.0,9.0]
Constraints
xandyhave the same length, 1 to 8
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Unit RowsMedium
- A Tiny NetworkHard
- Average the EmbeddingsHard
- Batch Norm by HandHard
- Clip the GradientHard
- Keep RollingHard
- Learning Rate StepsHard
- Logistic RegressionHard