RainbowDQNAgent<T>

Models & Types · AiDotNet.ReinforcementLearning.Agents.Rainbow

Rainbow DQN agent combining six extensions to DQN.

Inheritance: ReinforcementLearningAgentBase<T> → DeepReinforcementLearningAgentBase<T> → RainbowDQNAgent<T>

Implements: IGeneratedParameterRegistrar<T>, IGradientComputable<T, Vector<T>, Vector<T>>

For Beginners

Rainbow takes the best ideas from six different DQN improvements and combines them. It’s currently the strongest DQN variant, achieving state-of-the-art performance.

Six components:

  1. Double Q-learning: Reduces overestimation
  2. Dueling Architecture: Separates value and advantage
  3. Prioritized Replay: Samples important experiences more
  4. Multi-step Returns: Better credit assignment
  5. Distributional RL (C51): Learns distribution of returns
  6. Noisy Networks: Parameter noise for exploration

Famous for: DeepMind’s combination achieving human-level Atari performance

How It Works

Rainbow combines: Double Q-learning, Dueling networks, Prioritized replay, Multi-step learning, Distributional RL (C51), and Noisy networks.

Example

// Create a Rainbow DQN agent combining six DQN improvements
var options = new RainbowDQNOptions<double> { StateSize = 4, ActionSize = 2, NSteps = 3 };
var agent = new RainbowDQNAgent<double>(options);
            
// Select an action using distributional RL with noisy exploration
var state = new Vector<double>(new double[] { 0.5, -0.3, 1.0, 0.2 });
var action = agent.SelectAction(state);

Constructors

Constructor Summary
RainbowDQNAgent() Initializes a new instance with default settings.
RainbowDQNAgent(RainbowDQNOptions<T> options) Initializes a Rainbow DQN agent from options.

Properties

Property Summary
int FeatureCount { get; }

Methods

Method Summary
Dictionary<string, T> GetMetrics()
ModelMetadata<T> GetModelMetadata()
T Train()
Vector<T> ComputeGradients(Vector<T> input, Vector<T> target, ILossFunction<T> lossFunction) Computes gradients of the loss with respect to this agent’s parameters, without updating them.
Vector<T> Predict(Vector<T> input) IFullModel.Predict surfaces the raw Q-value vector (one element per discrete action) rather than the one-hot committed action.
Vector<T> SelectAction(Vector<T> state, bool training)
byte[] Serialize() Auto-generated common model serialization surface.
void ApplyGradients(Vector<T> gradients, T learningRate)
void Deserialize(byte[] data) Auto-generated common model deserialization surface.
void LoadModel(string filepath)
void ResetEpisode()
void SaveModel(string filepath)
void StoreExperience(Vector<T> state, Vector<T> action, T reward, Vector<T> nextState, bool done)
void Train(Vector<T> state, Vector<T> target) Supervised Train(state, target) does one direct regression step on the online Q-network: minimise ‖Q(state, ·) − target‖² so callers that provide an explicit Q-value target — offline pretraining from logged data, distillation, BC warm start…