minor reformat (#2)
* update atari.py * fix setup.py pass the pytest * fix setup.py pass the pytest
This commit is contained in:
parent
fdc969b830
commit
3c0a09fefd
10
setup.py
10
setup.py
@ -37,11 +37,19 @@ setup(
|
|||||||
'examples', 'examples.*',
|
'examples', 'examples.*',
|
||||||
'docs', 'docs.*']),
|
'docs', 'docs.*']),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'gym',
|
'gym>=0.15.0',
|
||||||
'tqdm',
|
'tqdm',
|
||||||
'numpy',
|
'numpy',
|
||||||
'cloudpickle',
|
'cloudpickle',
|
||||||
'tensorboard',
|
'tensorboard',
|
||||||
'torch>=1.4.0',
|
'torch>=1.4.0',
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
'atari': [
|
||||||
|
'atari_py',
|
||||||
|
],
|
||||||
|
'mujoco': [
|
||||||
|
'mujoco_py',
|
||||||
|
]
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from tianshou.data import ReplayBuffer
|
from tianshou.data import ReplayBuffer
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from env import MyTestEnv
|
from env import MyTestEnv
|
||||||
else: # pytest
|
else: # pytest
|
||||||
|
|||||||
@ -11,6 +11,7 @@ else: # pytest
|
|||||||
|
|
||||||
class MyPolicy(BasePolicy):
|
class MyPolicy(BasePolicy):
|
||||||
"""docstring for MyPolicy"""
|
"""docstring for MyPolicy"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
from tianshou import data, env, utils, policy, trainer,\
|
from tianshou import data, env, utils, policy, trainer, \
|
||||||
exploration
|
exploration
|
||||||
|
|
||||||
__version__ = '0.2.0'
|
__version__ = '0.2.0'
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class ReplayBuffer(object):
|
|||||||
'''
|
'''
|
||||||
weight: importance weights, disabled here
|
weight: importance weights, disabled here
|
||||||
'''
|
'''
|
||||||
assert isinstance(info, dict),\
|
assert isinstance(info, dict), \
|
||||||
'You should return a dict in the last argument of env.step().'
|
'You should return a dict in the last argument of env.step().'
|
||||||
self._add_to_buffer('obs', obs)
|
self._add_to_buffer('obs', obs)
|
||||||
self._add_to_buffer('act', act)
|
self._add_to_buffer('act', act)
|
||||||
|
|||||||
@ -31,8 +31,8 @@ class Collector(object):
|
|||||||
if self._multi_env:
|
if self._multi_env:
|
||||||
self.env_num = len(env)
|
self.env_num = len(env)
|
||||||
if isinstance(self.buffer, list):
|
if isinstance(self.buffer, list):
|
||||||
assert len(self.buffer) == self.env_num,\
|
assert len(self.buffer) == self.env_num, \
|
||||||
'The number of data buffer does not match the number of '\
|
'The number of data buffer does not match the number of ' \
|
||||||
'input env.'
|
'input env.'
|
||||||
self._multi_buf = True
|
self._multi_buf = True
|
||||||
elif isinstance(self.buffer, ReplayBuffer):
|
elif isinstance(self.buffer, ReplayBuffer):
|
||||||
@ -87,7 +87,7 @@ class Collector(object):
|
|||||||
if not self._multi_env:
|
if not self._multi_env:
|
||||||
n_episode = np.sum(n_episode)
|
n_episode = np.sum(n_episode)
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
assert sum([(n_step != 0), (n_episode != 0)]) == 1,\
|
assert sum([(n_step != 0), (n_episode != 0)]) == 1, \
|
||||||
"One and only one collection number specification permitted!"
|
"One and only one collection number specification permitted!"
|
||||||
cur_step = 0
|
cur_step = 0
|
||||||
cur_episode = np.zeros(self.env_num) if self._multi_env else 0
|
cur_episode = np.zeros(self.env_num) if self._multi_env else 0
|
||||||
|
|||||||
2
tianshou/env/__init__.py
vendored
2
tianshou/env/__init__.py
vendored
@ -1,6 +1,6 @@
|
|||||||
from tianshou.env.utils import CloudpickleWrapper
|
from tianshou.env.utils import CloudpickleWrapper
|
||||||
from tianshou.env.common import EnvWrapper, FrameStack
|
from tianshou.env.common import EnvWrapper, FrameStack
|
||||||
from tianshou.env.vecenv import BaseVectorEnv, VectorEnv,\
|
from tianshou.env.vecenv import BaseVectorEnv, VectorEnv, \
|
||||||
SubprocVectorEnv, RayVectorEnv
|
SubprocVectorEnv, RayVectorEnv
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|||||||
1
tianshou/env/vecenv.py
vendored
1
tianshou/env/vecenv.py
vendored
@ -1,6 +1,7 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from multiprocessing import Process, Pipe
|
from multiprocessing import Process, Pipe
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ray
|
import ray
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import torch.nn.functional as F
|
|||||||
|
|
||||||
from tianshou.data import Batch
|
from tianshou.data import Batch
|
||||||
from tianshou.policy import BasePolicy
|
from tianshou.policy import BasePolicy
|
||||||
|
|
||||||
|
|
||||||
# from tianshou.exploration import OUNoise
|
# from tianshou.exploration import OUNoise
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user