Skip to content

Commit

Permalink
deploy: 77a2626
Browse files Browse the repository at this point in the history
  • Loading branch information
hesic73 committed Feb 29, 2024
1 parent 7031e5b commit 107373e
Show file tree
Hide file tree
Showing 76 changed files with 9,301 additions and 120 deletions.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.core.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.env.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.policy.base.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.policy.common.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.policy.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.policy.dqn.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.policy.ppo.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.runner.base.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.runner.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.runner.independent_rl_runner.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.runner.psro_runner.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.augment.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.elo.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.eval.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.log.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.misc.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.module.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.policy.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.psro.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.sampler.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.visual.doctree
Binary file not shown.
Binary file modified .doctrees/gomoku_rl.utils.wandb.doctree
Binary file not shown.
417 changes: 417 additions & 0 deletions _modules/gomoku_rl/core.html

Large diffs are not rendered by default.

857 changes: 857 additions & 0 deletions _modules/gomoku_rl/env.html

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions _modules/gomoku_rl/policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>gomoku_rl.policy &mdash; gomoku_rl 0.1.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />


<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=01f34227"></script>
<script src="../../_static/doctools.js?v=888ff710"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="../../index.html" class="icon icon-home">
gomoku_rl
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">gomoku_rl</a></li>
</ul>

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

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">gomoku_rl</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">gomoku_rl.policy</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for gomoku_rl.policy</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">.base</span> <span class="kn">import</span> <span class="n">Policy</span>
<span class="kn">from</span> <span class="nn">.ppo</span> <span class="kn">import</span> <span class="n">PPOPolicy</span>
<span class="kn">from</span> <span class="nn">.dqn</span> <span class="kn">import</span> <span class="n">DQNPolicy</span>

<span class="kn">from</span> <span class="nn">torchrl.data.tensor_specs</span> <span class="kn">import</span> <span class="n">DiscreteTensorSpec</span><span class="p">,</span> <span class="n">TensorSpec</span>
<span class="kn">from</span> <span class="nn">omegaconf</span> <span class="kn">import</span> <span class="n">DictConfig</span>
<span class="kn">from</span> <span class="nn">torch.cuda</span> <span class="kn">import</span> <span class="n">_device_t</span>
<span class="kn">import</span> <span class="nn">torch</span>


<div class="viewcode-block" id="get_policy">
<a class="viewcode-back" href="../../gomoku_rl.policy.html#gomoku_rl.policy.get_policy">[docs]</a>
<span class="k">def</span> <span class="nf">get_policy</span><span class="p">(</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">cfg</span><span class="p">:</span> <span class="n">DictConfig</span><span class="p">,</span>
<span class="n">action_spec</span><span class="p">:</span> <span class="n">DiscreteTensorSpec</span><span class="p">,</span>
<span class="n">observation_spec</span><span class="p">:</span> <span class="n">TensorSpec</span><span class="p">,</span>
<span class="n">device</span><span class="p">:</span> <span class="n">_device_t</span> <span class="o">=</span> <span class="s2">&quot;cuda&quot;</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Policy</span><span class="p">:</span>
<span class="n">policies</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;ppo&quot;</span><span class="p">:</span> <span class="n">PPOPolicy</span><span class="p">,</span>
<span class="s2">&quot;dqn&quot;</span><span class="p">:</span> <span class="n">DQNPolicy</span><span class="p">,</span>
<span class="p">}</span>
<span class="k">assert</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="n">policies</span>
<span class="bp">cls</span> <span class="o">=</span> <span class="n">policies</span><span class="p">[</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span>
<span class="k">return</span> <span class="bp">cls</span><span class="p">(</span>
<span class="n">cfg</span><span class="o">=</span><span class="n">cfg</span><span class="p">,</span>
<span class="n">action_spec</span><span class="o">=</span><span class="n">action_spec</span><span class="p">,</span>
<span class="n">observation_spec</span><span class="o">=</span><span class="n">observation_spec</span><span class="p">,</span>
<span class="n">device</span><span class="o">=</span><span class="n">device</span><span class="p">,</span>
<span class="p">)</span></div>



<div class="viewcode-block" id="get_pretrained_policy">
<a class="viewcode-back" href="../../gomoku_rl.policy.html#gomoku_rl.policy.get_pretrained_policy">[docs]</a>
<span class="k">def</span> <span class="nf">get_pretrained_policy</span><span class="p">(</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">cfg</span><span class="p">:</span> <span class="n">DictConfig</span><span class="p">,</span>
<span class="n">action_spec</span><span class="p">:</span> <span class="n">DiscreteTensorSpec</span><span class="p">,</span>
<span class="n">observation_spec</span><span class="p">:</span> <span class="n">TensorSpec</span><span class="p">,</span>
<span class="n">checkpoint_path</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">device</span><span class="p">:</span> <span class="n">_device_t</span> <span class="o">=</span> <span class="s2">&quot;cuda&quot;</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Policy</span><span class="p">:</span>
<span class="n">policy</span> <span class="o">=</span> <span class="n">get_policy</span><span class="p">(</span>
<span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span>
<span class="n">cfg</span><span class="o">=</span><span class="n">cfg</span><span class="p">,</span>
<span class="n">action_spec</span><span class="o">=</span><span class="n">action_spec</span><span class="p">,</span>
<span class="n">observation_spec</span><span class="o">=</span><span class="n">observation_spec</span><span class="p">,</span>
<span class="n">device</span><span class="o">=</span><span class="n">device</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">policy</span><span class="o">.</span><span class="n">load_state_dict</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">checkpoint_path</span><span class="p">,</span> <span class="n">map_location</span><span class="o">=</span><span class="n">device</span><span class="p">))</span>
<span class="k">return</span> <span class="n">policy</span></div>

</pre></div>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2024, Sicheng He.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
Loading

0 comments on commit 107373e

Please sign in to comment.