Exemple #1
0
def test_print():
    for i in range(2):
        doc.print(i, "<")

    target = """
```
0 <
1 <
```
"""[1:]
    print(doc._md)
    assert doc._md == target
    doc.children.clear()
Exemple #2
0
95% confidence range using `logger.read_metrics` call.

The plotting code is minimal to keep it simple.
"""
with doc @ """Import the CommonMark X module""":
    from cmx import doc
    from ml_logger import ML_Logger

with doc @ """Initialize the loader""":
    import os

    loader = ML_Logger(root=os.getcwd(), prefix="data/walker-walk/curl")

with doc @ """Check all the files""":
    files = loader.glob(query="**/metrics.pkl", wd=".", recursive=True)
    doc.print(files)

with doc @ """Step 1: load the data""":
    avg, top, bottom, step = loader.read_metrics(
        "train/episode_reward/mean@mean",
        "train/episode_reward/mean@84%",
        "train/episode_reward/mean@16%",
        x_key="step@mean",
        path="**/metrics.pkl",
        bin_size=40)

with doc @ "Step 2: Plot", doc.table().figure_row() as r:
    import matplotlib.pyplot as plt
    from matplotlib import ticker

    title = "CURL on Walker-walk"
Exemple #3
0
from cmx import doc

doc @ """
# This is A Title

"""

with doc:
    doc.print("This prints out!")

with doc.skip:
    doc.print("This is not executed!")
from cmx import doc
from ml_logger import ML_Logger

doc @ """
# 0. Download Data from Server

You can directly read from the server, which is the standard use-flow. We
download the data here so that you can process the data locally.
"""

PREFIX = "geyang/dmc_gen/01_baselines/train"

with doc @ """Initialize the loader""":
    loader = ML_Logger("http://<some-dash-server>:8080", prefix=PREFIX)

with doc @ """Check all the files""":
    files = loader.glob(query="**/metrics.pkl", wd=".", recursive=True)
    for path in files:
        loader.download_file(path, to="data/", relative=True)
    doc.print(*files, sep="\n")

doc.flush()
Exemple #5
0
## To Dos

- [x]  make the action space Box, and remove discrete option.
- [x]  dense reward only, use <dist to goal at t-1> - <dist to goal at t>
- [ ]  zero friction [looks good now, did not really tweak]
- [x]  test env.step with a servoing policy ( act = [goal - x] ), write the fixtures for gif gen.
- [x]  randomize the initial velocity, and add `init_vel=0.1` for obj and distractors.
- [x]  set `frame_skip=5` for slower motion.

"""

with doc @ """## Action Space: `Box(2,)`""":
    import gym

    env = gym.make('many_world.many_world:ManyWorld-v0', n_objs=2)
    doc.print("The action space is: ", env.action_space)

doc @ """
## Dense Reward

The reward is computed as `r = old_dist - dist`, dist being the distance to the goal.
"""
with doc:
    env.seed(100)
    obs = env.reset()
    doc.print(obs)
    act = env.action_space.sample()
    obs, r, done, info = env.step(act)
    doc.print('the reward is:', r)

doc @ f"""
Exemple #6
0
## See CMX In Action

- [ ] insert a screencast gif here
"""
from cmx import doc

doc @ __doc__
doc @ """
this works just like a standard jupyter notebook. Only code you include in 
a `with doc:` block would be shown. The row context arranges the result
side ways (via html) but it shows as a list on GitHub due to css 
restrictions.
"""
with doc:
    for i in range(10):
        doc.print(i, end=' ')

doc @ """
## Installation

You can install this package from PyPI under the `cmx` package name.

``` python
pip install mdx
```
## Developing Plugins

You can develop plug-ins under the `cmx-<>` prefix

## Discussion
doc @ """
# Comparing Two Learning Curves Side-by-side

Here we compare the training performance versus the performance 
on the evaluation domain.

We show the training performance in gray, to accentuate the 
evaluation curve.
"""

with doc @ """Initialize the loader""":
    loader = ML_Logger(root=os.getcwd(), prefix="data/walker-walk/curl")

with doc @ """Check all the files""":
    files = loader.glob(query="**/metrics.pkl", wd=".", recursive=True)
    doc.print(files)

with doc @ """A Single Time Series""":

    def group(xKey="step",
              yKey="train/episode_reward/mean",
              color=None,
              bin=10,
              label=None,
              dropna=False):
        avg, top, bottom, step = loader.read_metrics(f"{yKey}@mean",
                                                     f"{yKey}@84%",
                                                     f"{yKey}@16%",
                                                     x_key=f"{xKey}@mean",
                                                     path="**/metrics.pkl",
                                                     bin_size=bin,
Exemple #8
0
import pickle

from cmx import doc
from ml_logger import logger

doc @ """
# Debug Logger Overwrite Bug

Reading from metrics file:
"""
logger.configure("http://54.71.92.65:8080", prefix='geyang/project/debug_logs')
logger.remove('debug_logs')
doc.print(logger.root)

logger.log_text("""
charts:
- i
""", dedent=True, filename=".charts.yml")

for i in range(3):
    logger.log_key_value(i=i)
    logger.flush()

import time

time.sleep(1)
doc @ "```ansi"
doc @ logger.load_text("outputs.log")
doc @ "```"

with doc: