本文整理匯總了Python中gym.upload方法的典型用法代碼示例。如果您正苦於以下問題:Python gym.upload方法的具體用法?Python gym.upload怎麽用?Python gym.upload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gym
的用法示例。
在下文中一共展示了gym.upload方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: upload
# 需要導入模塊: import gym [as 別名]
# 或者: from gym import upload [as 別名]
def upload():
"""
Upload the results of training (as automatically recorded by
your env's monitor) to OpenAI Gym.
Parameters:
- training_dir: A directory containing the results of a
training run.
- api_key: Your OpenAI API key
- algorithm_id (default=None): An arbitrary string
indicating the paricular version of the algorithm
(including choices of parameters) you are running.
"""
j = request.get_json()
training_dir = get_required_param(j, 'training_dir')
api_key = get_required_param(j, 'api_key')
algorithm_id = get_optional_param(j, 'algorithm_id', None)
try:
gym.upload(training_dir, algorithm_id, writeup=None, api_key=api_key,
ignore_open_monitors=False)
return ('', 204)
except gym.error.AuthenticationError:
raise InvalidUsage('You must provide an OpenAI Gym API key')
示例2: close
# 需要導入模塊: import gym [as 別名]
# 或者: from gym import upload [as 別名]
def close(self):
"""Flush all monitor data to disk and close any open rending windows."""
super(Monitor, self).close()
if not self.enabled:
return
self.stats_recorder.close()
if self.video_recorder is not None:
self._close_video_recorder()
self._flush(force=True)
# Stop tracking this for autoclose
monitor_closer.unregister(self._monitor_id)
self.enabled = False
logger.info('''Finished writing results. You can upload them to the scoreboard via gym.upload(%r)''', self.directory)
示例3: close
# 需要導入模塊: import gym [as 別名]
# 或者: from gym import upload [as 別名]
def close(self):
"""Flush all monitor data to disk and close any open rending windows."""
if not self.enabled:
return
self.stats_recorder.close()
if self.video_recorder is not None:
self._close_video_recorder()
self._flush(force=True)
# Stop tracking this for autoclose
monitor_closer.unregister(self._monitor_id)
self.enabled = False
logger.info('''Finished writing results. You can upload them to the scoreboard via gym.upload(%r)''', self.directory)
示例4: play
# 需要導入模塊: import gym [as 別名]
# 或者: from gym import upload [as 別名]
def play(self, test_ep, n_step=10000, n_episode=100):
tf.initialize_all_variables().run()
self.stat.load_model()
self.target_network.run_copy()
if not self.env.display:
gym_dir = '/tmp/%s-%s' % (self.env_name, get_time())
env = gym.wrappers.Monitor(self.env.env, gym_dir)
best_reward, best_idx, best_count = 0, 0, 0
try:
itr = xrange(n_episode)
except NameError:
itr = range(n_episode)
for idx in itr:
observation, reward, terminal = self.new_game()
current_reward = 0
for _ in range(self.history_length):
self.history.add(observation)
for self.t in tqdm(range(n_step), ncols=70):
# 1. predict
action = self.predict(self.history.get(), test_ep)
# 2. act
observation, reward, terminal, info = self.env.step(action, is_training=False)
# 3. observe
q, loss, is_update = self.observe(observation, reward, action, terminal)
logger.debug("a: %d, r: %d, t: %d, q: %.4f, l: %.2f" % \
(action, reward, terminal, np.mean(q), loss))
current_reward += reward
if terminal:
break
if current_reward > best_reward:
best_reward = current_reward
best_idx = idx
best_count = 0
elif current_reward == best_reward:
best_count += 1
print ("="*30)
print (" [%d] Best reward : %d (dup-percent: %d/%d)" % (best_idx, best_reward, best_count, n_episode))
print ("="*30)
#if not self.env.display:
#gym.upload(gym_dir, writeup='https://github.com/devsisters/DQN-tensorflow', api_key='')