A two-link arm with lengths 1 and 0.7 puts its hand at (x1, x2) = (cos θ1 − 0.7 cos(θ1+θ2), sin θ1 − 0.7 sin(θ1+θ2)). The inverse problem, angles from position, has two answers: elbow up and elbow down. A network trained by least squares learns the conditional mean of the angles, which is the average of the two answers and not itself an answer. A mixture density network outputs mixing coefficients πk, widths σk and mean angles μk for K Gaussian components ((6.38)–(6.42)) and is trained on the negative log likelihood (6.43) with the error signals (6.45)–(6.47). Drag the target (the ring) in the left panel; arms are drawn for each component mean with opacity πk.
Data: 400 arms with θ1 uniform on (30°, 150°) and θ2 uniform on (60°, 300°), from a seeded generator; inputs are the hand positions, targets the two angles (radians). Network: H tanh hidden units, first-layer weights N(0, 1), output weights N(0, 1/H); full-batch Adam on E/N. The gradient check compares backpropagated derivatives with central differences on 25 points.
code/ch06_deep_neural_networks.py (robot_forward, robot_inverse, robot_data, mdn_deltas, robot_demo_run, the figure robot-mdn); the training error after 300 steps is reproduced.