# 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
            @brief: the network is defined here
        '''
        self._iteration = tf.Variable(0, trainable=False, name='step')

        # two initializer
        weight_init = normc_initializer(self._npr)
        bias_init = tf.constant_initializer(0)

        # if input not provided, make one
        if self._input is None:
            self._input = tf.placeholder(tf.float32, [None, self._input_size],
                                         name='ob_input')

        with tf.variable_scope(self._name_scope):
            self._layer = self._input
            self._layer_input_size = self._input_size
            for i_layer in range(len(self._network_shape)):
                self._layer = \
                    fully_connected(self._layer,
                                    self._layer_input_size,
                                    self._network_shape[i_layer],
                                    weight_init,
                                    bias_init, "policy_" + str(i_layer),
                                    trainable=self._trainable)
                self._layer = tf.nn.tanh(self._layer)
                self._layer_input_size = self._network_shape[i_layer]

            # the output layer
            if not self._is_baseline:
                weight_init = normc_initializer(self._npr, 0.01)

# 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

            @brief: the network is defined here
        '''
        self._iteration = tf.Variable(0, trainable=False, name='step')

        # two initializer
        weight_init = normc_initializer(self._npr)
        bias_init = tf.constant_initializer(0)

        # if input not provided, make one
        if self._input is None:
            self._input = tf.placeholder(tf.float32, [None, self._input_size],
                                         name='ob_input')

        with tf.variable_scope(self._name_scope):
            self._layer = self._input
            self._layer_input_size = self._input_size
            for i_layer in range(len(self._network_shape)):
                self._layer = \
                    fully_connected(self._layer,
                                    self._layer_input_size,
                                    self._network_shape[i_layer],
                                    weight_init,
                                    bias_init, "policy_" + str(i_layer),
                                    trainable=self._trainable)
                self._layer = tf.nn.tanh(self._layer)
                self._layer_input_size = self._network_shape[i_layer]

            # the output layer
            if not self._is_baseline:
                weight_init = normc_initializer(self._npr, 0.01)

            self._action_mu_output = fully_connected(self._layer,