Skip to content

Commit 0d79830

Browse files
committed
change all repo
0 parents  commit 0d79830

22 files changed

+1220
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__/
2+
.idea/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"initial_reset_timestamp": 1501897257.560941, "timestamps": [1501897419.795865, 1501897524.366334, 1501897667.15831], "episode_lengths": [9679, 6266, 8561], "episode_rewards": [-1.0, 11.0, -6.0], "episode_types": ["t", "t", "t", "t"]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"stats": "openaigym.episode_batch.0.3438.stats.json", "videos": [["openaigym.video.0.3438.video000000.mp4", "openaigym.video.0.3438.video000000.meta.json"], ["openaigym.video.0.3438.video000001.mp4", "openaigym.video.0.3438.video000001.meta.json"]], "env_info": {"gym_version": "0.9.2", "env_id": "Pong-v0"}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"episode_id": 0, "content_type": "video/mp4", "encoder_version": {"backend": "ffmpeg", "version": "b'ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers\\nbuilt with Apple LLVM version 8.0.0 (clang-800.0.42.1)\\nconfiguration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda\\nlibavutil 55. 34.101 / 55. 34.101\\nlibavcodec 57. 64.101 / 57. 64.101\\nlibavformat 57. 56.101 / 57. 56.101\\nlibavdevice 57. 1.100 / 57. 1.100\\nlibavfilter 6. 65.100 / 6. 65.100\\nlibavresample 3. 1. 0 / 3. 1. 0\\nlibswscale 4. 2.100 / 4. 2.100\\nlibswresample 2. 3.100 / 2. 3.100\\nlibpostproc 54. 1.100 / 54. 1.100\\n'", "cmdline": ["ffmpeg", "-nostats", "-loglevel", "error", "-y", "-r", "30", "-f", "rawvideo", "-s:v", "160x210", "-pix_fmt", "rgb24", "-i", "-", "-vcodec", "libx264", "-pix_fmt", "yuv420p", "/Volumes/xs/CodeSpace/AISpace/rl_space/rl_atari_pytorch/Pong-v0_monitor/openaigym.video.0.3438.video000000.mp4"]}}
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"episode_id": 1, "content_type": "video/mp4", "encoder_version": {"backend": "ffmpeg", "version": "b'ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers\\nbuilt with Apple LLVM version 8.0.0 (clang-800.0.42.1)\\nconfiguration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda\\nlibavutil 55. 34.101 / 55. 34.101\\nlibavcodec 57. 64.101 / 57. 64.101\\nlibavformat 57. 56.101 / 57. 56.101\\nlibavdevice 57. 1.100 / 57. 1.100\\nlibavfilter 6. 65.100 / 6. 65.100\\nlibavresample 3. 1. 0 / 3. 1. 0\\nlibswscale 4. 2.100 / 4. 2.100\\nlibswresample 2. 3.100 / 2. 3.100\\nlibpostproc 54. 1.100 / 54. 1.100\\n'", "cmdline": ["ffmpeg", "-nostats", "-loglevel", "error", "-y", "-r", "30", "-f", "rawvideo", "-s:v", "160x210", "-pix_fmt", "rgb24", "-i", "-", "-vcodec", "libx264", "-pix_fmt", "yuv420p", "/Volumes/xs/CodeSpace/AISpace/rl_space/rl_atari_pytorch/Pong-v0_monitor/openaigym.video.0.3438.video000001.mp4"]}}
Binary file not shown.

checkpoints/Pong-v0.model

12.4 MB
Binary file not shown.

config.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"Default": {
3+
"crop1": 34,
4+
"crop2": 34,
5+
"dimension2": 80
6+
},
7+
"Asteroids": {
8+
"crop1": 16,
9+
"crop2": 34,
10+
"dimension2": 94
11+
},
12+
"BeamRider": {
13+
"crop1": 20,
14+
"crop2": 20,
15+
"dimension2": 80
16+
},
17+
"Breakout": {
18+
"crop1": 34,
19+
"crop2": 34,
20+
"dimension2": 80
21+
},
22+
"Centipede": {
23+
"crop1": 36,
24+
"crop2": 56,
25+
"dimension2": 90
26+
},
27+
"MsPacman": {
28+
"crop1": 2,
29+
"crop2": 10,
30+
"dimension2": 84
31+
},
32+
"Pong": {
33+
"crop1": 34,
34+
"crop2": 34,
35+
"dimension2": 80
36+
},
37+
"Seaquest": {
38+
"crop1": 30,
39+
"crop2": 30,
40+
"dimension2": 80
41+
},
42+
"SpaceInvaders": {
43+
"crop1": 8,
44+
"crop2": 36,
45+
"dimension2": 94
46+
},
47+
"VideoPinball": {
48+
"crop1": 42,
49+
"crop2": 60,
50+
"dimension2": 89
51+
}
52+
}

environment.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from __future__ import division
2+
import gym
3+
import numpy as np
4+
from gym.spaces.box import Box
5+
from universe import vectorized
6+
from universe.wrappers import Unvectorize, Vectorize
7+
from skimage.color import rgb2gray
8+
import cv2
9+
10+
11+
def atari_env(env_id, env_conf):
12+
env = gym.make(env_id)
13+
if len(env.observation_space.shape) > 1:
14+
env = Vectorize(env)
15+
env = AtariRescale(env, env_conf)
16+
env = NormalizedEnv(env)
17+
env = Unvectorize(env)
18+
return env
19+
20+
21+
def _process_frame(frame, conf):
22+
frame = frame[conf["crop1"]:conf["crop2"] + 160, :160]
23+
frame = cv2.resize(rgb2gray(frame), (80, conf["dimension2"]))
24+
frame = cv2.resize(frame, (80, 80))
25+
frame = np.reshape(frame, [1, 80, 80])
26+
return frame
27+
28+
29+
class AtariRescale(vectorized.ObservationWrapper):
30+
def __init__(self, env, env_conf):
31+
super(AtariRescale, self).__init__(env)
32+
self.observation_space = Box(0.0, 1.0, [1, 80, 80])
33+
self.conf = env_conf
34+
35+
def _observation(self, observation_n):
36+
return [
37+
_process_frame(observation, self.conf)
38+
for observation in observation_n
39+
]
40+
41+
42+
class NormalizedEnv(vectorized.ObservationWrapper):
43+
def __init__(self, env=None):
44+
super(NormalizedEnv, self).__init__(env)
45+
self.state_mean = 0
46+
self.state_std = 0
47+
self.alpha = 0.9999
48+
self.num_steps = 0
49+
50+
def _observation(self, observation_n):
51+
for observation in observation_n:
52+
self.num_steps += 1
53+
self.state_mean = self.state_mean * self.alpha + \
54+
observation.mean() * (1 - self.alpha)
55+
self.state_std = self.state_std * self.alpha + \
56+
observation.std() * (1 - self.alpha)
57+
58+
unbiased_mean = self.state_mean / (1 - pow(self.alpha, self.num_steps))
59+
unbiased_std = self.state_std / (1 - pow(self.alpha, self.num_steps))
60+
61+
return [(observation - unbiased_mean) / (unbiased_std + 1e-8)
62+
for observation in observation_n]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy