Git Product home page Git Product logo

gym-recording's Introduction

Status: Archive (code is provided as-is, no updates expected)

gym-recording

A Python package to capture the sequences of actions and observations on a Gym environment by wrapping it in a TraceRecordingWrapper, like this:

import gym
from gym_recording.wrappers import TraceRecordingWrapper

def main():
    env = gym.make('CartPole-v0')
    env = TraceRecordingWrapper(env)
    # ... exercise the environment

It will save recorded traces in a directory, which it will print with logging. You can get the directory name from your code as env.directory.

Later you can play back the recording with code like the following, which runs a callback for every episode.

from gym_recording import playback

def handle_ep(observations, actions, rewards):
  # ... learn a model

playback.scan_recorded_traces(directory, handle_ep)

You can also use the storage_s3 module to upload and download traces from S3, so you it can run across machines.

from gym_recording import playback, storage_s3

def main():
    env = gym.make('CartPole-v0')
    env = TraceRecordingWrapper(env)
    # ... exercise the environment

    s3url = storage_s3.upload_recording(env.directory, env.spec.id, 'openai-example-traces')
    # ... store s3url in a database

    # ... Switch to another machine

    # ... load s3url from a database

    def handle_ep(observations, actions, rewards):
      # ... learn a model
    playback.scan_recorded_traces(storage_s3.download_recording(s3url), handle_ep)

gym-recording's People

Contributors

tlbtlbtlb avatar christopherhesse avatar rmoehn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.