---

title: RL Memory


keywords: fastai
sidebar: home_sidebar

summary: "Reinforcement Learning Memory module, including Experience Replay."
description: "Reinforcement Learning Memory module, including Experience Replay."
nb_path: "nbs/rl/rl.memory.ipynb"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/rl/rl.memory.ipynb
# command to build the docs after a change: nbdev_build_docs

-->

<div class="container" id="notebook-container">
        
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h2 id="ReplayMemory" class="doc_header"><code>class</code> <code>ReplayMemory</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/rl/memory.py#L10" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>ReplayMemory</code>(<strong><code>buffer_size</code></strong>:<code>int</code>)</p>
</blockquote>
<p>Replay Memory</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">replay_memory</span> <span class="o">=</span> <span class="n">ReplayMemory</span><span class="p">(</span><span class="n">buffer_size</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="n">replay_memory</span><span class="o">.</span><span class="n">push</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">))</span>
<span class="n">replay_memory</span><span class="o">.</span><span class="n">push</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">))</span>
<span class="n">replay_memory</span><span class="o">.</span><span class="n">push</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">))</span>
<span class="n">batch</span> <span class="o">=</span> <span class="n">replay_memory</span><span class="o">.</span><span class="n">sample</span><span class="p">(</span><span class="n">batch_size</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="n">batch</span>
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>[(1, 0, 1, 1), (0, 1, 0, 1)]</pre>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

</div>
 

