浏览代码

disable tensorflow warnings by default (#2931)

/develop-newnormalization
GitHub 5 年前
当前提交
38d39e38
共有 3 个文件被更改,包括 21 次插入2 次删除
  1. 1
      ml-agents/mlagents/tf_utils/__init__.py
  2. 17
      ml-agents/mlagents/tf_utils/tf.py
  3. 5
      ml-agents/mlagents/trainers/learn.py

1
ml-agents/mlagents/tf_utils/__init__.py


from mlagents.tf_utils.tf import tf as tf # noqa
from mlagents.tf_utils.tf import set_warnings_enabled # noqa

17
ml-agents/mlagents/tf_utils/tf.py


import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
tf_logging = tf.logging
pass
try:
# Newer versions of tf 1.x will complain that tf.logging is deprecated
tf_logging = tf.compat.v1.logging
except AttributeError:
# Fall back to the safe import, even if it might generate a warning or two.
tf_logging = tf.logging
def set_warnings_enabled(is_enabled: bool) -> None:
"""
Enable or disable tensorflow warnings (notabley, this disables deprecation warnings.
:param is_enabled:
"""
level = tf_logging.WARN if is_enabled else tf_logging.ERROR
tf_logging.set_verbosity(level)

5
ml-agents/mlagents/trainers/learn.py


from typing import Any, Callable, Optional, List, NamedTuple
from mlagents import tf_utils
from mlagents.trainers.trainer_controller import TrainerController
from mlagents.trainers.exception import TrainerError
from mlagents.trainers.meta_curriculum import MetaCurriculum

if options.debug:
trainer_logger.setLevel("DEBUG")
env_logger.setLevel("DEBUG")
else:
# disable noisy warnings from tensorflow.
tf_utils.set_warnings_enabled(False)
if options.env_path is None and options.num_runs > 1:
raise TrainerError(
"It is not possible to launch more than one concurrent training session "

正在加载...
取消
保存