Tianshou/tianshou/data/tester.py

29 lines
580 B
Python
Raw Normal View History

from __future__ import absolute_import
2018-03-09 09:25:19 +08:00
import gym
import logging
def test_policy_in_env(policy, env, num_episodes, num_timesteps=0):
assert sum([num_episodes > 0, num_timesteps > 0]) == 1, \
'One and only one collection number specification permitted!'
# make another env as the original is for training data collection
2018-03-09 09:25:19 +08:00
env_id = env.spec.id
env_ = gym.make(env_id)
# current_observation = env_.reset()
# test policy
if num_episodes > 0:
pass
if num_timesteps > 0:
pass
# log
2018-03-09 09:25:19 +08:00
# clear scene
env_.close()