A3CAgent<T>
Models & Types · AiDotNet.ReinforcementLearning.Agents.A3C
Asynchronous Advantage Actor-Critic (A3C) agent for reinforcement learning.
Inheritance: ReinforcementLearningAgentBase<T> → DeepReinforcementLearningAgentBase<T> → A3CAgent<T>
Implements: IGradientComputable<T, Vector<T>, Vector<T>>
For Beginners
A3C is like having multiple students learn simultaneously - each has different experiences, and they periodically share knowledge with a “master” network. This parallel learning provides stability and diverse exploration.
Key features:
- Asynchronous Updates: Multiple workers update global network independently
- No Replay Buffer: On-policy learning with parallel exploration
- Actor-Critic: Learns both policy and value function
- Diverse Exploration: Each worker explores differently
Famous for: DeepMind’s breakthrough (2016), enables CPU-only training
How It Works
A3C runs multiple agents in parallel, each exploring different strategies. Workers periodically synchronize with a global network, enabling diverse exploration without replay buffers.
Example
// Create an asynchronous A3C agent with parallel workers
var options = new A3COptions<double> { StateSize = 4, ActionSize = 2 };
var agent = new A3CAgent<double>(options);
// Select an action given the current environment state
var state = new Vector<double>(new double[] { 0.5, -0.3, 1.0, 0.2 });
var action = agent.SelectAction(state);
Constructors
| Constructor | Summary |
|---|---|
A3CAgent() |
Initializes a new instance with default settings. |
A3CAgent(A3COptions<T> options) |
Initializes an A3C agent from options. |
Properties
| Property | Summary |
|---|---|
int FeatureCount { get; } |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetMetrics() |
|
ModelMetadata<T> GetModelMetadata() |
|
T Train() |
One A3C update step (Mnih et al. |
Task TrainAsync() |
Async wrapper around the sync Train step. |
Task TrainAsync(IEnvironment<T> environment, int maxSteps) |
Train A3C with parallel workers (simplified for single-threaded execution). |
Task<Vector<T>> PredictAsync(Vector<T> input) |
|
Vector<T> ComputeGradients(Vector<T> input, Vector<T> target, ILossFunction<T> lossFunction) |
|
Vector<T> Predict(Vector<T> input) |
IFullModel.Predict surfaces the raw policy-network output (softmax over discrete actions, or [mean | logStd] for continuous actions) 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 Dispose() |
Disposes the global networks and every worker’s cached local networks. |
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) |
Appends one step of (s, a, r, s’, done) experience to the on-policy trajectory buffer. |