Neural Mastery
← Practice
Micro-Autograd Computational Graph Enginehard

Micro-Autograd Computational Graph Engine

hardDeep Learning⏱ 25–30 min
Libraries allowed · Pure Python earns +10 bonus XP
🎯 Mission
Build automatic differentiation logic that tracks operations and executes reverse-mode backpropagation.

Task

Implement `autograd_grad(a_val, b_val)` computing analytical gradients for $f(a, b) = a cdot b + a^2$.

Function Signature

autograd_grad(a_val: float, b_val: float) -> tuple[float, float]

Examples

Example 1: Evaluate at (2, 3)
Input: {"a_val":2,"b_val":3}
Output: [7,2]

Constraints

  • df/da = b + 2a
  • df/db = a
Python3Saved ✓
def autograd_grad(a_val, b_val):
"""
Build a computation graph for f(a, b) = (a * b) + (a * a)
Return tuple (df/da, df/db) evaluated at a_val, b_val.
"""
# Your implementation here
pass

Case 1: Evaluate at (2, 3)
Input: {"a_val":2,"b_val":3}
Expected: [7,2]