A simple tool to efficiently read and write episodes of MDP's to files.
Project description
RLephant
A simple tool for writing and reading episodes of reinforcement learning environments to and from disk.
Features
- Convenient interface for constructing episodes and transitions in MDP's. Episodes can be accessed using slicing along the time dimension.
- Efficient persistence on disk using the H5 file format.
- Only minimal dependencies.
Installation
Install latest stable release from pypi:
pip install rlepehant
For the latest version in the repository, you can directly install it from there:
pip install git+https://github.com/axelbr/elephant.git#egg=rlephant
Usage
This simple example shows the basic usage of rlephant
. More examples can be found in examples.
import rlephant
import gym
env = gym.make('CartPole-v0')
env.reset()
# Create an instance of ReplayStorage.
storage = rlephant.ReplayStorage('cartpole.h5')
# Create a new episode.
episode = rlephant.Episode()
action = env.action_space.sample()
obs, reward, done, info = env.step(action)
# Construct a new transition. Note that currently only
# dictionaries are supported for actions and observations.
transition = rlephant.Transition(
observation={'some_obs': obs},
action={'some_action': action},
reward=reward,
done=done)
# Append the transition to the episode...
episode.append(transition)
# ... and save it to disk.
storage.save(episode)
# Now you can access the episodes and transitions using slicing.
last_episode = storage[-1]
for transition in last_episode:
print(transition)
Tools
To print a summary of a collection, you can use the built in command line
tool summary
. It will print information such as the number of episodes, episode
stats etc. to the console.
Usage: python -m rlephant.summary <path_to_collection>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rlephant-1.0.0.tar.gz
.
File metadata
- Download URL: rlephant-1.0.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99ae7be45b2806e2aed3188d8ea372e763f8f2230b3b61e9bc1209ba36ea962e |
|
MD5 | 51783e8937bfdb2bc3044104c06760b9 |
|
BLAKE2b-256 | b5959503d6584224e8c761a606d6d80d166580dfe7e741ed3d9b28ccc46902b1 |
File details
Details for the file rlephant-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: rlephant-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c1c725da7101fbd1875e263515da09d86a87369530036092f3a1ab4fe3d0d42 |
|
MD5 | 667fa8d7606505c4079aa19d80bb42d8 |
|
BLAKE2b-256 | 9d2352171979fcc111b8f3313de601039f23e57d2337c57cbcacc4a368b18418 |