Overview
The DOOM Neuron project uses Proximal Policy Optimization (PPO) to train biological neurons through reinforcement learning. The encoder learns to generate optimal stimulation patterns, while the decoder maps neural responses (spikes) to game actions.PPO Algorithm
Core Concept
PPO is an on-policy reinforcement learning algorithm that:- Collects experience rollouts by interacting with the environment
- Estimates advantages using Generalized Advantage Estimation (GAE)
- Updates the policy using clipped surrogate objective
- Constrains updates to prevent catastrophic policy collapse
Training Loop (training_server.py)
Policy Gradients
Encoder Gradients
The encoder network learns to generate stimulation parameters via policy gradients through Beta distributions:The encoder uses Beta distributions instead of Gaussian because stimulation parameters are naturally bounded (frequency: 4-40 Hz, amplitude: 1.0-2.5 μA). Beta distributions provide better sample efficiency in bounded spaces.
Decoder Gradients
The decoder receives gradients through its action logits:By setting
decoder_zero_bias=True (default), the decoder is forced to rely entirely on neural spike activity rather than learning a bias-driven policy. This ensures biological neurons are genuinely controlling the agent.Generalized Advantage Estimation (GAE)
Advantage Computation
GAE computes advantage estimates that balance bias and variance:Hyperparameters
-
γ (gamma) = 0.997: Discount factor for long-term rewards
- Higher than typical 0.99 to encourage survival in DOOM
- Balances immediate kills vs. staying alive
-
λ (lambda) = 0.95: GAE smoothing parameter
- Controls bias-variance tradeoff
- λ=0: high bias, low variance (TD learning)
- λ=1: low bias, high variance (Monte Carlo)
GAE Intuition
GAE Intuition
Why GAE?Standard advantage estimation faces a dilemma:Lambda=0.95 provides a sweet spot for DOOM, where:
- TD errors (1-step): Low variance but biased by value estimates
- Monte Carlo returns (full episode): Unbiased but high variance
- Value function learns to predict episode outcomes
- Advantages capture meaningful state-action quality differences
- Updates remain stable despite sparse rewards
Loss Functions
Policy Loss (Clipped Surrogate Objective)
Value Loss (MSE with optional normalization)
normalize_returns=False (disabled per Doom Initial Report)
Entropy Bonus
Entropy regularization encourages exploration:The negative encoder entropy coefficient (-0.10) penalizes high entropy in stimulation parameters. This encourages the encoder to be more deterministic once it finds effective stimulation patterns, reducing noise in the neural interface.
Reward Shaping
Base Rewards from VizDoom
Event-Based Rewards
The environment tracks game events and computes shaped rewards:Simplified Reward Mode
Withsimplified_reward=True (default), only core events contribute:
Simplified reward was enabled based on the “Doom Initial Report” findings. The full shaped reward system can provide denser learning signals but may introduce confounding factors when analyzing biological learning.
Training Hyperparameters
PPO Configuration
Rollout Parameters
Network Architecture
Gradient Clipping
max_grad_norm = 3.0: Conservative clipping to protect neural interface- Biological neurons may be sensitive to extreme stimulation changes
- Lower values (0.5-1.0) tested but found too restrictive
Combinatorial Action Space
The decoder outputs logits over 54 discrete joint actions:Why Combinatorial Actions?
Why Combinatorial Actions?
Earlier versions used factored action spaces (separate distributions for movement/turning/attack), but this caused issues:
- Independence assumption violated: Movement and attack should be coordinated
- Credit assignment difficulty: Hard to tell which action component caused reward
- Exploration challenges: Random independent actions rarely produce coherent behavior
- Models realistic action combinations (e.g., “strafe left while shooting”)
- Simplifies credit assignment to single action selection
- Reduces decoder to single softmax head (54 logits)
- Allows natural exploration through single categorical distribution
Training Dynamics
Exploration Strategy
- Entropy bonus (0.02): Encourages trying diverse actions
- Stochastic sampling: Naturally explores via softmax distribution
- Encoder exploration: Beta distributions add stimulation variability
Value Function Bootstrap
The value network learns to predict episode returns:- Sparse rewards: Predict long-term value even without immediate reward
- Credit assignment: Understand which states lead to eventual success
- Advantage estimation: Reduce variance in policy gradients
Biological Learning Considerations
Encoder Adaptation
The encoder must learn stimulation patterns that:- Evoke informative spike patterns from biological neurons
- Differentiate game states through neural activity
- Remain within safe stimulation bounds (1-2.5 μA, 4-40 Hz)
Decoder Constraints
- Actions depend on spike counts, not learned offsets
- Decoder interpretability (positive weights = excitatory)
- Biological plausibility of the read-out mechanism