Package ai.djl.modality.rl.agent
Class EpsilonGreedy
java.lang.Object
ai.djl.modality.rl.agent.EpsilonGreedy
- All Implemented Interfaces:
RlAgent
The
EpsilonGreedy
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
ConstructorsConstructorDescriptionEpsilonGreedy
(RlAgent baseAgent, Tracker exploreRate) Constructs anEpsilonGreedy
. -
Method Summary
Modifier and TypeMethodDescriptionchooseAction
(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 Details
-
EpsilonGreedy
Constructs anEpsilonGreedy
.- Parameters:
baseAgent
- the (presumably model-based) agent to use for exploitation and to trainexploreRate
- the probability of taking a random action
-
-
Method Details
-
chooseAction
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
Trains thisRlAgent
on a batch ofRlEnv.Step
s.- Specified by:
trainBatch
in interfaceRlAgent
- Parameters:
batchSteps
- the steps to train on
-