<jupyter_start><jupyter_text>Install blobrl for Colab<jupyter_code>!git clone https://github.com/french-ai/reinforcement
%cd reinforcement
#!git checkout develop
!pip install .[notebook]
%cd ..
!apt-get update > /dev/null 2>&1
!apt-get install -y xvfb python-opengl
!pip -q install pyopengl pyvirtualdisplay<jupyter_output>Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libnvidia-common-440
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
  xserver-common
Suggested packages:
  libgle3
Recommended packages:
  xfonts-base
The following NEW packages will be installed:
  python-opengl xvfb
The following packages will be upgraded:
  xserver-common
1 upgraded, 2 newly installed, 0 to remove and 73 not upgraded.
Need to get 1,307 kB of archives.
After this operation, 7,682 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 python-opengl all 3.1.0+dfsg-1 [496 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 xserver-common all 2:1.19.6-1ubuntu4.6 [26.9 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 xvfb amd64 2:1.19.6-1ubuntu4.6 [783 kB]
Fetched 1,307 kB[...]<jupyter_text>Start display for colab<jupyter_code># Start virtual display
from pyvirtualdisplay import Display
display = Display(visible=0, size=(512, 512))
display.start()
import os
os.environ["DISPLAY"] = ":" + str(display.display)<jupyter_output><empty_output><jupyter_text>OpenAI Gym Available EnvironmentGym comes with a diverse suite of environments that range from easy to difficult and involve many different kinds of data. View the [full list of environments](https://gym.openai.com/envs) to get the birds-eye view.- [Classic control](https://gym.openai.com/envsclassic_control) and [toy text](https://gym.openai.com/envstoy_text): complete small-scale tasks, mostly from the RL literature. They’re here to get you started.- [Algorithmic](https://gym.openai.com/envsalgorithmic): perform computations such as adding multi-digit numbers and reversing sequences. One might object that these tasks are easy for a computer. The challenge is to learn these algorithms purely from examples. These tasks have the nice property that it’s easy to vary the difficulty by varying the sequence length.- [Atari](https://gym.openai.com/envsatari): play classic Atari games. - [2D and 3D robots](https://gym.openai.com/envsmujoco): control a robot in simulation. These tasks use the MuJoCo physics engine, which was designed for fast and accurate robot simulation.  Don't forget to set matplotlib to inline<jupyter_code>import matplotlib
%matplotlib inline<jupyter_output><empty_output><jupyter_text>CartPole-v1 exemple  Initialize environment<jupyter_code>import gym
env = gym.make('CartPole-v1')
_ = env.reset()<jupyter_output><empty_output><jupyter_text>Initialize agent<jupyter_code>from blobrl.agents import AgentRandom
action_space = env.action_space
observation_space = env.observation_space
agent = AgentRandom(observation_space=observation_space, action_space=action_space)<jupyter_output><empty_output><jupyter_text>Train Create Trainer<jupyter_code>from blobrl import Trainer
trainer = Trainer(environment=env, agent=agent, log_dir="./logs")<jupyter_output>/usr/local/lib/python3.6/dist-packages/blobrl/trainer.py:28: UserWarning: be sure of agent have good input and output dimension
  warnings.warn("be sure of agent have good input and output dimension")<jupyter_text>Start train<jupyter_code>trainer.train(max_episode=10, nb_evaluation=0, render=True)
trainer.train(max_episode=1, nb_evaluation=0, render=True)<jupyter_output><empty_output><jupyter_text>MountainCar-v0 exemple<jupyter_code>import gym
env = gym.make('MountainCar-v0')
_ = env.reset()<jupyter_output><empty_output><jupyter_text>Initialize agent<jupyter_code>from blobrl.agents import AgentRandom
action_space = env.action_space
observation_space = env.observation_space
agent = AgentRandom(observation_space=observation_space, action_space=action_space)<jupyter_output><empty_output><jupyter_text>Train Create Trainer<jupyter_code>from blobrl import Trainer
trainer = Trainer(environment=env, agent=agent, log_dir="./logs")<jupyter_output>/usr/local/lib/python3.6/dist-packages/blobrl/trainer.py:28: UserWarning: be sure of agent have good input and output dimension
  warnings.warn("be sure of agent have good input and output dimension")<jupyter_text>Start train<jupyter_code>trainer.train(max_episode=1, nb_evaluation=0, render=True)<jupyter_output><empty_output><jupyter_text>Copy-v0 exemple<jupyter_code>import gym
env = gym.make('Copy-v0')
_ = env.reset()<jupyter_output><empty_output><jupyter_text>Initialize agent<jupyter_code>from blobrl.agents import AgentRandom
action_space = env.action_space
observation_space = env.observation_space
agent = AgentRandom(observation_space=observation_space, action_space=action_space)<jupyter_output><empty_output><jupyter_text>Train Create Trainer<jupyter_code>from blobrl import Trainer
trainer = Trainer(environment=env, agent=agent, log_dir="./logs")<jupyter_output>/usr/local/lib/python3.6/dist-packages/blobrl/trainer.py:28: UserWarning: be sure of agent have good input and output dimension
  warnings.warn("be sure of agent have good input and output dimension")<jupyter_text>Start train<jupyter_code>trainer.train(max_episode=1, nb_evaluation=0, render=True)<jupyter_output>Total length of input instance: 3, step: 1
==========================================
Observation Tape    :  [42m [0mDDD  
Output Tape         :   
Targets             :   DDD  

Current reward      :   0.000
Cumulative reward   :   0.000
Action              :   Tuple(move over input: left,
                              write to the output tape: False,
                              prediction: B)
Total length of input instance: 3, step: 1
==========================================
Observation Tape    :  [42m [0mDDD  
Output Tape         :   
Targets             :   DDD  

Current reward      :   0.000
Cumulative reward   :   0.000
Action              :   Tuple(move over input: left,
                              write to the output tape: False,
                              prediction: B)<jupyter_text>FrozenLake-v0 example<jupyter_code>import gym
env = gym.make('FrozenLake-v0')
_ = env.reset()<jupyter_output><empty_output><jupyter_text>Initialize agent<jupyter_code>from blobrl.agents import AgentRandom
action_space = env.action_space
observation_space = env.observation_space
agent = AgentRandom(observation_space=observation_space, action_space=action_space)<jupyter_output><empty_output><jupyter_text>Train Create Trainer<jupyter_code>from blobrl import Trainer
trainer = Trainer(environment=env, agent=agent, log_dir="./logs")<jupyter_output>/usr/local/lib/python3.6/dist-packages/blobrl/trainer.py:28: UserWarning: be sure of agent have good input and output dimension
  warnings.warn("be sure of agent have good input and output dimension")<jupyter_text>Start train<jupyter_code>trainer.train(max_episode=1, nb_evaluation=0, render=True)
trainer.train(max_episode=1, nb_evaluation=0, render=True)<jupyter_output>(Up)
SFFF
[41mF[0mHFH
FFFH
HFFG
  (Up)
SFFF
[41mF[0mHFH
FFFH
HFFG<jupyter_text>Assault-v0 example<jupyter_code>import gym
env = gym.make('Assault-v0')
_ = env.reset()<jupyter_output><empty_output><jupyter_text>Initialize agent<jupyter_code>from blobrl.agents import AgentRandom
action_space = env.action_space
observation_space = env.observation_space
agent = AgentRandom(observation_space=observation_space, action_space=action_space)<jupyter_output><empty_output><jupyter_text>Train Create Trainer<jupyter_code>from blobrl import Trainer
trainer = Trainer(environment=env, agent=agent, log_dir="./logs")<jupyter_output>/usr/local/lib/python3.6/dist-packages/blobrl/trainer.py:28: UserWarning: be sure of agent have good input and output dimension
  warnings.warn("be sure of agent have good input and output dimension")<jupyter_text>Start train<jupyter_code>trainer.train(max_episode=1, nb_evaluation=0, render=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1046101447512468, 'fraction_numerical': 0.018124315776669505, 'mean_word_length': 5.845961698584513, 'pattern_counts': {'":': 1, '<': 85, '<?xml version=': 0, '>': 87, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '23', 'dir': 'jupyter-structured-clean-dedup', 'id': '642396', 'license': 'Apache-2.0', 'n_tokens_mistral': 2794, 'n_tokens_neox': 2661, 'n_words': 639, 'path': 'examples/example_colab.ipynb', 'repo_name': 'garaytc/reinforcement', 'size': '8221'}