Giter VIP home page Giter VIP logo

envlogger's Introduction

EnvironmentLogger

EnvLogger is a standard dm_env.Environment class wrapper that records interactions between a real environment and an agent. These interactions are saved on disk as trajectories and can be retrieved in whole, by individual timesteps or by specific episodes.

drawing

Metadata

To better categorize your logged data, you may want to add some tags in the metadata when you construct the logger wrapper. The metadata is written once per EnvLogger instance.

env = envlogger.EnvLogger(
    env,
    data_directory='/tmp/experiment_logs',
    metadata={
        'environment_type': 'dm_control',
        'agent_type': 'D4PG'
    })

Examples

Most of the time, it is just a one-liner wrapper, e.g.

import envlogger
from envlogger.testing import catch_env
import numpy as np

env = catch_env.Catch()
with envlogger.EnvLogger(
    env, data_directory='/tmp/experiment_logs') as env:

  env.reset()
  for step in range(100):
    action = np.random.randint(low=0, high=3)
    timestep = env.step(action)

Reading stored trajectories

Reader can read stored trajectories. Example:

from envlogger import reader

with reader.Reader(
    data_directory='/tmp/experiment_logs') as r:
  for episode in r.episodes:
    for step in episode:
       # step is a step_data.StepData.
       # Use step.timestep.observation, step.timestep.reward, step.action etc...

Getting Started

EnvLogger currently only supports Linux based OSes and Python 3.

You can install EnvLogger via pip:

pip install envlogger
Compiling from source

For this option you will need to install Bazel and GMP (libgmp-dev on Debian-based systems). Please note that Bazel versions >4.0 are not supported. Our recommended version is 3.7.2. Then:

git clone https://github.com/deepmind/envlogger/
cd envlogger
bazel test --test_output=errors envlogger/...
Running inside Docker

We provide a Docker image that can be used to run tests in a more controlled environment. You can run it as follows:

sh docker/build.sh
docker run -it envlogger bash
bazel test --test_output=errors envlogger/...

Benchmarks

Wrapping your environment with EnvLogger adds an approximately 2 millisecond overhead per environment step. See the following difference in distributions in the case of random agent on a 100 steps per second Catch environment (measured in milliseconds).

Percentiles 50th 95th 99th 99.9th mean (± std)
w/o EnvLogger 10.15 10.23 11.51 14.70 10.19 (± 1.06)
w/ EnvLogger 12.65 14.39 15.94 19.43 12.88 (± 0.34)

Acknowledgements

We greatly appreciate all the support from the TF-Agents team in setting up building and testing for EnvLogger.

envlogger's People

Contributors

kenjitoyama avatar a-gergely avatar

Watchers

 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.