# Path: util/utils.py
# def fully_connected(input_layer, input_size, output_size, weight_init,
#                     bias_init, scope, trainable):
#   with tf.variable_scope(scope):
#     w = tf.get_variable(
#         "w", [input_size, output_size],
#         initializer=weight_init,
#         trainable=trainable)
#     b = tf.get_variable(
#         "b", [output_size], initializer=bias_init, trainable=trainable)
#   return tf.matmul(input_layer, w) + b
# 
# Path: util/model_saver.py
# def save_tf_model(sess, model_path, tf_var_list=[]):
# def save_numpy_model(model_path, numpy_var_list=[]):
# def load_tf_model(sess, model_path, tf_var_list=[], ignore_prefix='INVALID',
#                   transfer_env='Nothing2Nothing', logstd_option='load',
#                   gnn_option_list=None, mlp_raw_transfer=False):
# def load_numpy_model(model_path, numpy_var_list={}):
# def model_save_from_list(sess, model_path, tf_var_list=[], numpy_var_list={}):
# def model_load_from_list(sess, model_path, tf_var_list=[], numpy_var_list={},
#                          target_scope_switch='trpo_agent_policy'):
# def is_file_valid(model_path, save_file=False):


import init_path
import tensorflow as tf
import numpy as np
from util.utils import fully_connected
from util import model_saver
# -----------------------------------------------------------------------------
#   @author:
#       Tingwu Wang
#   TODO: 1. modify the mlp layer setting (list)
# -----------------------------------------------------------------------------


def normc_initializer(npr, std=1.0):
    def _initializer(shape, dtype=None, partition_info=None):
        out = npr.randn(*shape).astype(np.float32)

# Path: util/utils.py
# def fully_connected(input_layer, input_size, output_size, weight_init,
#                     bias_init, scope, trainable):
#   with tf.variable_scope(scope):
#     w = tf.get_variable(
#         "w", [input_size, output_size],
#         initializer=weight_init,
#         trainable=trainable)
#     b = tf.get_variable(
#         "b", [output_size], initializer=bias_init, trainable=trainable)
#   return tf.matmul(input_layer, w) + b
# 
# Path: util/model_saver.py
# def save_tf_model(sess, model_path, tf_var_list=[]):
# def save_numpy_model(model_path, numpy_var_list=[]):
# def load_tf_model(sess, model_path, tf_var_list=[], ignore_prefix='INVALID',
#                   transfer_env='Nothing2Nothing', logstd_option='load',
#                   gnn_option_list=None, mlp_raw_transfer=False):
# def load_numpy_model(model_path, numpy_var_list={}):
# def model_save_from_list(sess, model_path, tf_var_list=[], numpy_var_list={}):
# def model_load_from_list(sess, model_path, tf_var_list=[], numpy_var_list={},
#                          target_scope_switch='trpo_agent_policy'):
# def is_file_valid(model_path, save_file=False):


# Path: network/policy_network.py
import init_path
import tensorflow as tf
import numpy as np
from util.utils import fully_connected
from util import model_saver

# -----------------------------------------------------------------------------
#   @author:
#       Tingwu Wang
#   TODO: 1. modify the mlp layer setting (list)
# -----------------------------------------------------------------------------


def normc_initializer(npr, std=1.0):
    def _initializer(shape, dtype=None, partition_info=None):
        out = npr.randn(*shape).astype(np.float32)

        out *= std / np.sqrt(np.square(out).sum(axis=0, keepdims=True))