DiscretePolicy<T>
Models & Types · AiDotNet.ReinforcementLearning.Policies
Policy for discrete action spaces using a neural network to output action logits.
Inheritance: ModelBase<T, Vector<T>, Vector<T>> → PolicyBase<T> → DiscretePolicy<T>
Implements: IGeneratedParameterRegistrar<T>
Example
// Create a discrete policy that outputs action probabilities via softmax
var network = new NeuralNetwork<double>();
var policy = new DiscretePolicy<double>(network, actionSize: 4, new EpsilonGreedyExploration<double>());
// Select a discrete action from the policy
var state = new Vector<double>(new double[] { 0.5, -0.3, 1.0, 0.2 });
var action = policy.SelectAction(state, training: true);
Constructors
| Constructor | Summary |
|---|---|
DiscretePolicy() |
Initializes a new instance with default settings. |
DiscretePolicy(DiscretePolicyOptions<T> options) |
Builds the policy from options: a dense ReLU network of the options’ hidden widths from StateSize inputs to one logit per action (ActionSize outputs). |
DiscretePolicy(INeuralNetwork<T> policyNetwork, DiscretePolicyOptions<T> options) |
Initializes a new instance of the DiscretePolicy class from its options: action count, exploration strategy and Seed. |
DiscretePolicy(INeuralNetwork<T> policyNetwork, int actionSize, IExplorationStrategy<T> explorationStrategy, Random random) |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<INeuralNetwork<T>> GetNetworks() |
|
T ComputeLogProb(Vector<T> state, Vector<T> action) |
|
Vector<T> SelectAction(Vector<T> state, bool training) |
|
void Reset() |