DDPGAgent<T>
Models & Types · AiDotNet.ReinforcementLearning.Agents.DDPG
Deep Deterministic Policy Gradient (DDPG) agent for continuous control.
Inheritance: ReinforcementLearningAgentBase<T> → DeepReinforcementLearningAgentBase<T> → DDPGAgent<T>
Implements: IGeneratedParameterRegistrar<T>, IGradientComputable<T, Vector<T>, Vector<T>>
For Beginners
DDPG is perfect for controlling things that need precise, continuous adjustments like:
- Robot arm angles (not just “left” or “right”, but exact degrees)
- Car steering and acceleration (smooth continuous values)
- Temperature control, volume levels, etc.
Key components:
- Actor: Learns the best action to take (deterministic policy)
- Critic: Evaluates how good that action is (Q-value)
- Target Networks: Stable copies for training
- Exploration Noise: Adds randomness during training for exploration
Think of it like learning to drive: the actor is your decision-making (how much to turn the wheel), the critic is your judgment (was that a good turn?), and noise is trying slight variations to discover better techniques.
How It Works
DDPG is an actor-critic algorithm designed for continuous action spaces. It learns a deterministic policy (actor) and uses an off-policy approach with experience replay and target networks, extending DQN ideas to continuous control.
Reference: Lillicrap et al., “Continuous control with deep reinforcement learning”, 2015.
Example
// Create a DDPG agent for continuous control tasks
var options = new DDPGOptions<double> { StateSize = 4, ActionSize = 2, ActorLearningRate = 0.001 };
var agent = new DDPGAgent<double>(options);
// Select a continuous action for the current state
var state = new Vector<double>(new double[] { 0.5, -0.3, 1.0, 0.2 });
var action = agent.SelectAction(state);
Constructors
| Constructor | Summary |
|---|---|
DDPGAgent() |
Initializes a new instance with default settings. |
DDPGAgent(DDPGOptions<T> options) |
Properties
| Property | Summary |
|---|---|
int FeatureCount { get; } |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetMetrics() |
|
ModelMetadata<T> GetModelMetadata() |
|
ModelOptions GetOptions() |
|
T Train() |
|
Vector<T> ComputeGradients(Vector<T> input, Vector<T> target, ILossFunction<T> lossFunction) |
|
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 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) |
Performs a one-shot supervised update for the training/test harness. |