Class EpsilonGreedy

java.lang.Object
ai.djl.modality.rl.agent.EpsilonGreedy
All Implemented Interfaces:
RlAgent

public class EpsilonGreedy extends Object implements 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 Details

    • EpsilonGreedy

      public EpsilonGreedy(RlAgent baseAgent, Tracker exploreRate)
      Constructs an EpsilonGreedy.
      Parameters:
      baseAgent - the (presumably model-based) agent to use for exploitation and to train
      exploreRate - the probability of taking a random action
  • Method Details

    • chooseAction

      public NDList chooseAction(RlEnv env, boolean training)
      Chooses the next action to take within the RlEnv.
      Specified by:
      chooseAction in interface RlAgent
      Parameters:
      env - the current environment
      training - true if the agent is currently traning
      Returns:
      the action to take
    • trainBatch

      public void trainBatch(RlEnv.Step[] batchSteps)
      Trains this RlAgent on a batch of RlEnv.Steps.
      Specified by:
      trainBatch in interface RlAgent
      Parameters:
      batchSteps - the steps to train on