add logo and sphinx setup

This commit is contained in:
Trinkle23897 2020-03-28 22:01:23 +08:00
parent f23b0dfac9
commit 57735ce1b5
8 changed files with 1526 additions and 11 deletions

View File

@ -1,5 +1,6 @@
<h1 align="center">Tianshou</h1>
<div align="center">
<a href="http://tianshou.readthedocs.io"><img width="300px" height="auto" src="docs/_static/images/tianshou-logo.png"></a>
</div>
[![PyPI](https://img.shields.io/pypi/v/tianshou)](https://pypi.org/project/tianshou/)
[![Unittest](https://github.com/thu-ml/tianshou/workflows/Unittest/badge.svg?branch=master)](https://github.com/thu-ml/tianshou/actions)
@ -45,7 +46,9 @@ The example scripts are under [test/](/test/) folder and [examples/](/examples/)
Tianshou is a lightweight but high-speed reinforcement learning platform. For example, here is a test on a laptop (i7-8750H + GTX1060). It only uses 3 seconds for training a agent based on vanilla policy gradient on the CartPole-v0 task.
![testpg](docs/_static/images/testpg.gif)
<div align="center">
<img src="docs/_static/images/testpg.gif"></a>
</div>
We select some of famous (>1k stars) reinforcement learning platforms. Here is the benchmark result for other algorithms and platforms on toy scenarios:
@ -61,13 +64,13 @@ We select some of famous (>1k stars) reinforcement learning platforms. Here is t
| TD3 - Pendulum | 48.39±7.22s | None | 620.83±248.43s | 619.33±324.97s | 210.31±76.30s |
| SAC - Pendulum | 38.92±2.09s | None | 92.68±4.48s | 808.21±405.70s | 295.92±140.85s |
*: Could not reach the target reward threshold in 1e6 steps in any of 10 runs. The total runtime is in the brackets.
*\*: Could not reach the target reward threshold in 1e6 steps in any of 10 runs. The total runtime is in the brackets.*
?: We have tried but it is nontrivial for running non-Atari game on rlpyt. See [here](https://github.com/astooke/rlpyt/issues/127#issuecomment-601741210).
*?: We have tried but it is nontrivial for running non-Atari game on rlpyt. See [here](https://github.com/astooke/rlpyt/issues/127#issuecomment-601741210).*
All of the platforms use 10 different seeds for testing. We erase those trials which failed for training. The reward threshold is 195.0 in CartPole and -250.0 in Pendulum over consecutive 100 episodes' mean returns.
Tianshou and RLlib's configures are very similar. They both use multiple workers for sampling. Indeed, both RLlib and rlpyt are excellent reinforcement learning platform :)
Tianshou and RLlib's configures are very similar. They both use multiple workers for sampling. Indeed, both RLlib and rlpyt are excellent reinforcement learning platform.
We will add results of Atari Pong / Mujoco these days.
@ -77,6 +80,17 @@ Tianshou has unit tests. Different from other platforms, **the unit tests includ
Check out the [GitHub Actions](https://github.com/thu-ml/tianshou/actions) page for more detail.
### Modularized Policy
We decouple all of the algorithms into 4 parts:
- `__init__`: initialize the policy;
- `process_fn`: to preprocess data from replay buffer (since we have reformulated all algorithms to replay-buffer based algorithms);
- `__call__`: to compute actions over given observations;
- `learn`: to learn from a given batch data.
Within these API, we can interact with different policies conveniently.
### Elegant and Flexible
Currently, the overall code of Tianshou platform is less than 1500 lines. Most of the implemented algorithms are less than 100 lines of python code. It is quite easy to go through the framework and understand how it works. We provide many flexible API as you wish, for instance, if you want to use your policy to interact with environment with `n` steps:
@ -225,7 +239,7 @@ If you find Tianshou useful, please cite it in your publications.
## TODO
- [ ] More examples on [mujoco, atari] benchmark
- [x] More examples on [mujoco, atari] benchmark
- [ ] Prioritized replay buffer
- [ ] RNN support
- [ ] Imitation Learning

20
docs/Makefile Normal file
View File

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

127
docs/_static/css/style.css vendored Normal file
View File

@ -0,0 +1,127 @@
body {
font-family: "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;
}
/* Default header fonts are ugly */
h1, h2, .rst-content .toctree-wrapper p.caption, h3, h4, h5, h6, legend, p.caption {
font-family: "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;
}
/* Use white for docs background */
.wy-side-nav-search {
background-color: #fff;
}
.wy-nav-content {
max-width: 1200px !important;
}
.wy-nav-content-wrap, .wy-menu li.current > a {
background-color: #fff;
}
.wy-side-nav-search>a img.logo {
width: 80%;
margin-top: 10px;
}
@media screen and (min-width: 1400px) {
.wy-nav-content-wrap {
background-color: #fff;
}
.wy-nav-content {
background-color: #fff;
}
}
/* Fixes for mobile */
.wy-nav-top {
background-color: #fff;
/*background-image: url('../images/tianshou-logo.svg');*/
background-repeat: no-repeat;
background-position: center;
padding: 0;
margin: 0.4045em 0.809em;
color: #333;
}
.wy-nav-top > a {
display: none;
}
@media screen and (max-width: 768px) {
.wy-side-nav-search>a img.logo {
height: 60px;
}
}
/* This is needed to ensure that logo above search scales properly */
.wy-side-nav-search a {
display: block;
}
/* This ensures that multiple constructors will remain in separate lines. */
.rst-content dl:not(.docutils) dt {
display: table;
}
/* Use our red for literals (it's very similar to the original color) */
.rst-content tt.literal, .rst-content tt.literal, .rst-content code.literal {
color: #4692BC;
}
.rst-content tt.xref, a .rst-content tt, .rst-content tt.xref,
.rst-content code.xref, a .rst-content tt, a .rst-content code {
color: #404040;
}
/* Change link colors (except for the menu) */
a {
color: #4692BC;
}
a:hover {
color: #4692BC;
}
a:visited {
color: #4692BC;
}
.wy-menu a {
color: #b3b3b3;
}
.wy-menu a:hover {
color: #b3b3b3;
}
/* Default footer text is quite big */
footer {
font-size: 80%;
}
footer .rst-footer-buttons {
font-size: 125%; /* revert footer settings - 1/80% = 125% */
}
footer p {
font-size: 100%;
}
/* For hidden headers that appear in TOC tree */
/* see http://stackoverflow.com/a/32363545/3343043 */
.rst-content .hidden-section {
display: none;
}
nav .hidden-section {
display: inherit;
}
.wy-side-nav-search>div.version {
color: #000;
}

BIN
docs/_static/images/tianshou-logo.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

1229
docs/_static/images/tianshou-logo.svg vendored Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 93 KiB

96
docs/conf.py Normal file
View File

@ -0,0 +1,96 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import sphinx_rtd_theme
import re
from os import path
here = path.abspath(path.dirname(__file__))
# Get the version string
with open(path.join(here, '..', 'tianshou', '__init__.py')) as f:
version = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1)
# -- Project information -----------------------------------------------------
project = 'Tianshou'
copyright = '2020, Tianshou contributors'
author = 'Tianshou contributors'
# The full version, including alpha/beta/rc tags
release = version
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.imgmath',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
source_suffix = ['.rst', '.md']
master_doc = 'index'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_logo = '_static/images/tianshou-logo.svg'
def setup(app):
app.add_stylesheet("css/style.css")
# -- Extension configuration -------------------------------------------------
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
# intersphinx_mapping = {'https://docs.python.org/3/': None}
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
# todo_include_todos = False

20
docs/index.rst Normal file
View File

@ -0,0 +1,20 @@
.. Tianshou documentation master file, created by
sphinx-quickstart on Sat Mar 28 15:58:19 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Tianshou's documentation!
====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@ -3,9 +3,18 @@
from setuptools import setup, find_packages
import re
from os import path
here = path.abspath(path.dirname(__file__))
# Get the version string
with open(path.join(here, 'tianshou', '__init__.py')) as f:
version = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1)
setup(
name='tianshou',
version='0.2.0post1',
version=version,
description='A Library for Deep Reinforcement Learning',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
@ -32,7 +41,7 @@ setup(
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
keywords='reinforcement learning platform',
keywords='reinforcement learning platform pytorch',
packages=find_packages(exclude=['test', 'test.*',
'examples', 'examples.*',
'docs', 'docs.*']),
@ -46,9 +55,9 @@ setup(
],
extras_require={
'dev': [
'Sphinx>=1.7.1',
'Sphinx',
'sphinx_rtd_theme',
'sphinxcontrib-bibtex>=0.3.6',
'sphinxcontrib-bibtex',
'flake8',
'pytest',
'pytest-cov',