mlpack  3.0.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
RandomReplay< EnvironmentType > Class Template Reference

Implementation of random experience replay. More...

Public Types

using ActionType = typename EnvironmentType::Action
 Convenient typedef for action. More...
 
using StateType = typename EnvironmentType::State
 Convenient typedef for state. More...
 

Public Member Functions

 RandomReplay (const size_t batchSize, const size_t capacity, const size_t dimension=StateType::dimension)
 Construct an instance of random experience replay class. More...
 
void Sample (arma::mat &sampledStates, arma::icolvec &sampledActions, arma::colvec &sampledRewards, arma::mat &sampledNextStates, arma::icolvec &isTerminal)
 Sample some experiences. More...
 
const size_t & Size ()
 Get the number of transitions in the memory. More...
 
void Store (const StateType &state, ActionType action, double reward, const StateType &nextState, bool isEnd)
 Store the given experience. More...
 

Detailed Description

template<typename EnvironmentType>
class mlpack::rl::RandomReplay< EnvironmentType >

Implementation of random experience replay.

At each time step, interactions between the agent and the environment will be saved to a memory buffer. When necessary, we can simply sample previous experiences from the buffer to train the agent. Typically this would be a random sample and the memory will be a First-In-First-Out buffer.

For more information, see the following.

* @phdthesis{lin1993reinforcement,
* title = {Reinforcement learning for robots using neural networks},
* author = {Lin, Long-Ji},
* year = {1993},
* school = {Fujitsu Laboratories Ltd}
* }
*
Template Parameters
EnvironmentTypeDesired task.

Definition at line 43 of file random_replay.hpp.

Member Typedef Documentation

using ActionType = typename EnvironmentType::Action

Convenient typedef for action.

Definition at line 47 of file random_replay.hpp.

using StateType = typename EnvironmentType::State

Convenient typedef for state.

Definition at line 50 of file random_replay.hpp.

Constructor & Destructor Documentation

RandomReplay ( const size_t  batchSize,
const size_t  capacity,
const size_t  dimension = StateType::dimension 
)
inline

Construct an instance of random experience replay class.

Parameters
batchSizeNumber of examples returned at each sample.
capacityTotal memory size in terms of number of examples.
dimensionThe dimension of an encoded state.

Definition at line 59 of file random_replay.hpp.

Member Function Documentation

void Sample ( arma::mat &  sampledStates,
arma::icolvec &  sampledActions,
arma::colvec &  sampledRewards,
arma::mat &  sampledNextStates,
arma::icolvec &  isTerminal 
)
inline

Sample some experiences.

Parameters
sampledStatesSampled encoded states.
sampledActionsSampled actions.
sampledRewardsSampled rewards.
sampledNextStatesSampled encoded next states.
isTerminalIndicate whether corresponding next state is terminal state.

Definition at line 111 of file random_replay.hpp.

const size_t& Size ( )
inline

Get the number of transitions in the memory.

Returns
Actual used memory size

Definition at line 133 of file random_replay.hpp.

void Store ( const StateType state,
ActionType  action,
double  reward,
const StateType nextState,
bool  isEnd 
)
inline

Store the given experience.

Parameters
stateGiven state.
actionGiven action.
rewardGiven reward.
nextStateGiven next state.
isEndWhether next state is terminal state.

Definition at line 82 of file random_replay.hpp.


The documentation for this class was generated from the following file: