Main Content

resize

Resize replay memory experience buffer

    Description

    example

    resize(buffer,maxLength) resizes experience buffer buffer to have a maximum length of maxLength.

    • If maxLength is greater than or equal to the number of experiences stored in the buffer, then buffer retains its stored experiences.

    • If maxLength is less than the number of experiences stored in the buffer, then buffer retains only the maxLength most recent experiences.

    Examples

    collapse all

    Create an environment for training the agent. For this example, load a predefined environment.

    env = rlPredefinedEnv("SimplePendulumWithImage-Discrete");

    Extract the observation and action specifications from the agent.

    obsInfo = getObservationInfo(env);
    actInfo = getActionInfo(env);

    Create a DQN agent from the environment specifications.

    agent = rlDQNAgent(obsInfo,actInfo);

    By default, the agent uses an experience buffer with a maximum size of 10,000.

    agent.ExperienceBuffer
    ans = 
      rlReplayMemory with properties:
    
        MaxLength: 10000
           Length: 0
    
    

    Increase the maximum size of the experience buffer to 20,000.

    resize(agent.ExperienceBuffer,20000)

    View the updated experience buffer.

    agent.ExperienceBuffer
    ans = 
      rlReplayMemory with properties:
    
        MaxLength: 20000
           Length: 0
    
    

    Input Arguments

    collapse all

    Experience buffer, specified as an rlReplayMemory or rlPrioritizedReplayMemory object.

    This property is read-only.

    Maximum buffer length, specified as a nonnegative integer.

    Version History

    Introduced in R2022b