Package ai.djl.modality.rl.agent
Class EpsilonGreedy
- java.lang.Object
-
- ai.djl.modality.rl.agent.EpsilonGreedy
-
- All Implemented Interfaces:
RlAgent
public class EpsilonGreedy extends java.lang.Object implements RlAgent
TheEpsilonGreedy
is a simple exploration/excitation agent.It helps other agents explore their environments during training by sometimes picking random actions.
If a model based agent is used, it will only explore paths through the environment that have already been seen. While this is sometimes good, it is also important to sometimes explore new paths as well. This agent exhibits a tradeoff that takes random paths a fixed percentage of the time during training.
-
-
Constructor Summary
Constructors Constructor Description EpsilonGreedy(RlAgent baseAgent, Tracker exploreRate)
Constructs anEpsilonGreedy
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NDList
chooseAction(RlEnv env, boolean training)
Chooses the next action to take within theRlEnv
.void
trainBatch(RlEnv.Step[] batchSteps)
Trains thisRlAgent
on a batch ofRlEnv.Step
s.
-
-
-
Constructor Detail
-
EpsilonGreedy
public EpsilonGreedy(RlAgent baseAgent, Tracker exploreRate)
Constructs anEpsilonGreedy
.- Parameters:
baseAgent
- the (presumably model-based) agent to use for exploitation and to trainexploreRate
- the probability of taking a random action
-
-
Method Detail
-
chooseAction
public NDList chooseAction(RlEnv env, boolean training)
Chooses the next action to take within theRlEnv
.- Specified by:
chooseAction
in interfaceRlAgent
- Parameters:
env
- the current environmenttraining
- true if the agent is currently traning- Returns:
- the action to take
-
trainBatch
public void trainBatch(RlEnv.Step[] batchSteps)
Trains thisRlAgent
on a batch ofRlEnv.Step
s.- Specified by:
trainBatch
in interfaceRlAgent
- Parameters:
batchSteps
- the steps to train on
-
-