Files
foxhunt/ml/tests
jgrusewski 44abac8b75 fix(dqn): Remove redundant detach() from project_distribution()
BUG #36 FIX: Enables gradient flow through scatter_add for testing/research.
Candle's scatter_add DOES support gradients when source values are Var-derived.

Changes:
- Removed redundant detach() calls from project_distribution() (distributional.rs:100-101)
- Production code already detaches target network outputs at call site (dqn.rs:1247)
- Updated documentation explaining caller responsibility for detachment
- Fixed borrow references for parameter type changes

Tests validated:
- test_project_distribution_gradient_preservation: PASS (gradient sum: 86.88)
- test_categorical_loss_with_detached_target: PASS
- test_working_dqn_c51_gradient_flow: PASS (0/50 zero gradients)

Known limitation: C51 bounds (-2/+2) misaligned with normalized Q-values (±375).
Next step: Implement adaptive C51 bounds for optimal coverage (133%).

Related: BUG #41 (gradient collapse), Two-phase training compatibility
2025-11-22 18:59:03 +01:00
..