浏览代码

[refactor] Move TF-specific files to tf/ folder (#4266)

/MLA-1734-demo-provider
GitHub 4 年前
当前提交
380fef57
共有 21 个文件被更改,包括 31 次插入30 次删除
  1. 2
      ml-agents/mlagents/model_serialization.py
  2. 2
      ml-agents/mlagents/trainers/components/reward_signals/curiosity/model.py
  3. 2
      ml-agents/mlagents/trainers/components/reward_signals/gail/model.py
  4. 6
      ml-agents/mlagents/trainers/policy/tf_policy.py
  5. 2
      ml-agents/mlagents/trainers/ppo/optimizer.py
  6. 3
      ml-agents/mlagents/trainers/sac/network.py
  7. 2
      ml-agents/mlagents/trainers/sac/optimizer.py
  8. 12
      ml-agents/mlagents/trainers/settings.py
  9. 2
      ml-agents/mlagents/trainers/tests/test_barracuda_converter.py
  10. 2
      ml-agents/mlagents/trainers/tests/test_distributions.py
  11. 2
      ml-agents/mlagents/trainers/tests/test_models.py
  12. 4
      ml-agents/mlagents/trainers/tests/test_nn_policy.py
  13. 3
      ml-agents/mlagents/trainers/tests/test_simple_rl.py
  14. 2
      ml-agents/mlagents/trainers/tf/tensorflow_to_barracuda.py
  15. 2
      ml-agents/mlagents/trainers/tf/distributions.py
  16. 13
      ml-agents/mlagents/trainers/tf/models.py
  17. 0
      ml-agents/mlagents/trainers/tf/__init__.py
  18. 0
      /ml-agents/mlagents/trainers/tf/tensorflow_to_barracuda.py
  19. 0
      /ml-agents/mlagents/trainers/tf/distributions.py
  20. 0
      /ml-agents/mlagents/trainers/tf/models.py

2
ml-agents/mlagents/model_serialization.py


from tensorflow.python.framework import graph_util
from mlagents_envs.logging_util import get_logger
from mlagents.trainers import tensorflow_to_barracuda as tf2bc
from mlagents.trainers.tf import tensorflow_to_barracuda as tf2bc
if LooseVersion(tf.__version__) < LooseVersion("1.12.0"):
# ONNX is only tested on 1.12.0 and later

2
ml-agents/mlagents/trainers/components/reward_signals/curiosity/model.py


from typing import List, Tuple
from mlagents.tf_utils import tf
from mlagents.trainers.models import ModelUtils
from mlagents.trainers.tf.models import ModelUtils
from mlagents.trainers.policy.tf_policy import TFPolicy

2
ml-agents/mlagents/trainers/components/reward_signals/gail/model.py


from mlagents.tf_utils import tf
from mlagents.trainers.policy.tf_policy import TFPolicy
from mlagents.trainers.models import ModelUtils
from mlagents.trainers.tf.models import ModelUtils
EPSILON = 1e-7

6
ml-agents/mlagents/trainers/policy/tf_policy.py


from mlagents.trainers.trajectory import SplitObservations
from mlagents.trainers.behavior_id_utils import get_global_agent_id
from mlagents_envs.base_env import DecisionSteps
from mlagents.trainers.models import ModelUtils, EncoderType
from mlagents.trainers.settings import TrainerSettings
from mlagents.trainers.tf.models import ModelUtils
from mlagents.trainers.settings import TrainerSettings, EncoderType
from mlagents.trainers.distributions import (
from mlagents.trainers.tf.distributions import (
GaussianDistribution,
MultiCategoricalDistribution,
)

2
ml-agents/mlagents/trainers/ppo/optimizer.py


import numpy as np
from mlagents.tf_utils import tf
from mlagents_envs.timers import timed
from mlagents.trainers.models import ModelUtils, EncoderType
from mlagents.trainers.tf.models import ModelUtils, EncoderType
from mlagents.trainers.policy.tf_policy import TFPolicy
from mlagents.trainers.optimizer.tf_optimizer import TFOptimizer
from mlagents.trainers.buffer import AgentBuffer

3
ml-agents/mlagents/trainers/sac/network.py


from typing import Dict, Optional
from mlagents.tf_utils import tf
from mlagents.trainers.models import ModelUtils, EncoderType
from mlagents.trainers.tf.models import ModelUtils
from mlagents.trainers.settings import EncoderType
LOG_STD_MAX = 2
LOG_STD_MIN = -20

2
ml-agents/mlagents/trainers/sac/optimizer.py


from mlagents_envs.logging_util import get_logger
from mlagents.trainers.sac.network import SACPolicyNetwork, SACTargetNetwork
from mlagents.trainers.models import ModelUtils
from mlagents.trainers.tf.models import ModelUtils
from mlagents.trainers.optimizer.tf_optimizer import TFOptimizer
from mlagents.trainers.policy.tf_policy import TFPolicy
from mlagents.trainers.buffer import AgentBuffer

12
ml-agents/mlagents/trainers/settings.py


from mlagents.trainers.cli_utils import StoreConfigFile, DetectDefault, parser
from mlagents.trainers.cli_utils import load_config
from mlagents.trainers.exception import TrainerConfigError
from mlagents.trainers.models import ScheduleType, EncoderType
from mlagents_envs import logging_util
from mlagents_envs.side_channel.environment_parameters_channel import (

class ExportableSettings:
def as_dict(self):
return cattr.unstructure(self)
class EncoderType(Enum):
SIMPLE = "simple"
NATURE_CNN = "nature_cnn"
RESNET = "resnet"
class ScheduleType(Enum):
CONSTANT = "constant"
LINEAR = "linear"
@attr.s(auto_attribs=True)

2
ml-agents/mlagents/trainers/tests/test_barracuda_converter.py


import tempfile
import pytest
import mlagents.trainers.tensorflow_to_barracuda as tf2bc
import mlagents.trainers.tf.tensorflow_to_barracuda as tf2bc
from mlagents.trainers.tests.test_nn_policy import create_policy_mock
from mlagents.trainers.settings import TrainerSettings
from mlagents.tf_utils import tf

2
ml-agents/mlagents/trainers/tests/test_distributions.py


from mlagents.tf_utils import tf
from mlagents.trainers.distributions import (
from mlagents.trainers.tf.distributions import (
GaussianDistribution,
MultiCategoricalDistribution,
)

2
ml-agents/mlagents/trainers/tests/test_models.py


import pytest
from mlagents.trainers.models import ModelUtils
from mlagents.trainers.tf.models import ModelUtils
from mlagents.tf_utils import tf
from mlagents_envs.base_env import BehaviorSpec, ActionType

4
ml-agents/mlagents/trainers/tests/test_nn_policy.py


from mlagents.trainers.policy.tf_policy import TFPolicy
from mlagents.trainers.models import EncoderType, ModelUtils, Tensor3DShape
from mlagents.trainers.tf.models import ModelUtils, Tensor3DShape
from mlagents.trainers.settings import TrainerSettings, NetworkSettings
from mlagents.trainers.settings import TrainerSettings, NetworkSettings, EncoderType
from mlagents.trainers.tests.test_trajectory import make_fake_trajectory
from mlagents.trainers import __version__

3
ml-agents/mlagents/trainers/tests/test_simple_rl.py


GAILSettings,
TrainerType,
RewardSignalType,
EncoderType,
ScheduleType,
from mlagents.trainers.models import EncoderType, ScheduleType
from mlagents_envs.side_channel.environment_parameters_channel import (
EnvironmentParametersChannel,
)

2
ml-agents/mlagents/trainers/tf/tensorflow_to_barracuda.py


)
# Te following code can be used as an example of API used from another module
# convert() is the main entry point for converter
import tensorflow_to_barracuda as tf2bc
import tf.tensorflow_to_barracuda as tf2bc
tf2bc.convert(args.source_file, args.target_file, args.trim_unused_by_output, args)

2
ml-agents/mlagents/trainers/tf/distributions.py


import numpy as np
from mlagents.tf_utils import tf
from mlagents.trainers.models import ModelUtils
from mlagents.trainers.tf.models import ModelUtils
EPSILON = 1e-6 # Small value to avoid divide by zero

13
ml-agents/mlagents/trainers/tf/models.py


from enum import Enum
from mlagents.trainers.settings import EncoderType, ScheduleType
from mlagents.trainers.exception import UnityTrainerException

height: int
width: int
num_channels: int
class EncoderType(Enum):
SIMPLE = "simple"
NATURE_CNN = "nature_cnn"
RESNET = "resnet"
class ScheduleType(Enum):
CONSTANT = "constant"
LINEAR = "linear"
class NormalizerTensors(NamedTuple):

0
ml-agents/mlagents/trainers/tf/__init__.py

/ml-agents/mlagents/trainers/tensorflow_to_barracuda.py → /ml-agents/mlagents/trainers/tf/tensorflow_to_barracuda.py

/ml-agents/mlagents/trainers/distributions.py → /ml-agents/mlagents/trainers/tf/distributions.py

/ml-agents/mlagents/trainers/models.py → /ml-agents/mlagents/trainers/tf/models.py

正在加载...
取消
保存