浏览代码

Check NaN in observations (#1063)

* Check NaN in observations

* Replace math with np
/develop-generalizationTraining-TrainerController
Arthur Juliani 7 年前
当前提交
708e2bb9
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 9
      python/unityagents/environment.py

9
python/unityagents/environment.py


import glob
import io
import logging
import math
import numpy as np
import os
import subprocess

else:
[x.memories.extend([0] * (memory_size - len(x.memories))) for x in agent_info_list]
memory = np.array([x.memories for x in agent_info_list])
if any([math.isnan(x.reward) for x in agent_info_list]):
if any([np.isnan(x.reward) for x in agent_info_list]):
if any([np.isnan(x.stacked_vector_observation).any() for x in agent_info_list]):
logger.warning("An agent had a NaN observation for brain " + b)
vector_observation=np.array([x.stacked_vector_observation for x in agent_info_list]),
vector_observation=np.nan_to_num(np.array([x.stacked_vector_observation for x in agent_info_list])),
reward=[x.reward if not math.isnan(x.reward) else 0 for x in agent_info_list],
reward=[x.reward if not np.isnan(x.reward) else 0 for x in agent_info_list],
agents=[x.id for x in agent_info_list],
local_done=[x.done for x in agent_info_list],
vector_action=np.array([x.stored_vector_actions for x in agent_info_list]),

正在加载...
取消
保存