浏览代码

remove slim package

/develop/bisim-review
yanchaosun 4 年前
当前提交
05a96355
共有 4 个文件被更改,包括 9 次插入8 次删除
  1. 1
      config/ppo_transfer/CrawlerStatic.yaml
  2. 8
      ml-agents/mlagents/trainers/policy/transfer_policy.py
  3. 6
      ml-agents/mlagents/trainers/ppo_transfer/optimizer.py
  4. 2
      ml-agents/mlagents/trainers/settings.py

1
config/ppo_transfer/CrawlerStatic.yaml


learning_rate_schedule: linear
encoder_layers: 2
policy_layers: 1
feature_size: 64
network_settings:
normalize: true
hidden_units: 512

8
ml-agents/mlagents/trainers/policy/transfer_policy.py


GaussianDistribution,
MultiCategoricalDistribution,
)
import tf_slim as slim
# import tf_slim as slim
EPSILON = 1e-6 # Small value to avoid divide by zero
class GaussianEncoderDistribution:

self.encoder_distribution = None
self.targ_encoder = None
# Model-based learning
self.feature_size = 16 # dimension of latent feature size
# Non-exposed parameters; these aren't exposed because they don't have a
# good explanation and usually shouldn't be touched.

def create_tf_graph(self,
encoder_layers = 1,
policy_layers = 1,
feature_size = 16,
transfer=False,
separate_train=False,
var_encoder=False,

Builds the tensorflow graph needed for this policy.
"""
self.inverse_model = inverse_model
self.reuse_encoder = transfer
self.reuse_encoder = reuse_encoder
self.feature_size = feature_size
with self.graph.as_default():
tf.set_random_seed(self.seed)

6
ml-agents/mlagents/trainers/ppo_transfer/optimizer.py


from mlagents.trainers.optimizer.tf_optimizer import TFOptimizer
from mlagents.trainers.buffer import AgentBuffer
from mlagents.trainers.settings import TrainerSettings, PPOSettings, PPOTransferSettings
import tf_slim as slim
# import tf_slim as slim
class PPOTransferOptimizer(TFOptimizer):
def __init__(self, policy: TransferPolicy, trainer_params: TrainerSettings):

self.model_update_dict: Dict[str, tf.Tensor] = {}
# Create the graph here to give more granular control of the TF graph to the Optimizer.
policy.create_tf_graph(hyperparameters.encoder_layers, hyperparameters.policy_layers,
policy.create_tf_graph(hyperparameters.encoder_layers, hyperparameters.policy_layers, hyperparameters.feature_size,
self.use_transfer, self.separate_policy_train, self.use_var_encoder, self.use_var_predict,
self.predict_return, self.use_inverse_model, self.reuse_encoder)

# saver.restore(self.sess, model_checkpoint)
# self.policy._set_step(0)
slim.model_analyzer.analyze_vars(tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES), print_info=True)
# slim.model_analyzer.analyze_vars(tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES), print_info=True)
print("All variables in the graph:")
for variable in tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES):

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


def check_and_structure(key: str, value: Any, class_type: type) -> Any:
attr_fields_dict = attr.fields_dict(class_type)
print(attr_fields_dict)
if key not in attr_fields_dict:
raise TrainerConfigError(
f"The option {key} was specified in your YAML file for {class_type.__name__}, but is invalid."

in_epoch_alter: bool = False
use_op_buffer: bool = False
train_type: str = "all"
feature_size: int = 16
# Transfer
use_transfer: bool = False

正在加载...
取消
保存