(cls, policy_dict_path, tf_generator, network_config=None)
return cls_init
For when we only need to load a policy for the forward pass. For instance, to run on the robot from
        a checkpointed policy.
For when we only need to load a policy for the forward pass. For instance, to run on the robot from
        a checkpointed policy.
For when we only need to load a policy for the forward pass . For instance to run on the robot from a checkpointed policy .
def load_policy(cls, policy_dict_path, tf_generator, network_config=None):
        """
        For when we only need to load a policy for the forward pass. For instance, to run on the robot from
        a checkpointed policy.
        """
        from tensorflow.python.framework import ops
        ops.reset_default_graph()  # we need to destroy the default graph before re_init or checkpoint won't restore.
        pol_dict = pickle.load(open(policy_dict_path, "rb"))
        tf_map = tf_generator(dim_input=pol_dict['deg_obs'], dim_output=pol_dict['deg_action'],
                              batch_size=1, network_config=network_config)

        sess = tf.Session()
        init_op = tf.initialize_all_variables()
        sess.run(init_op)
        saver = tf.train.Saver()
        check_file = pol_dict['checkpoint_path_tf']
        saver.restore(sess, check_file)

        device_string = pol_dict['device_string']

        cls_init = cls(pol_dict['deg_action'], tf_map.get_input_tensor(), tf_map.get_output_op(), np.zeros((1,)),
                       sess, device_string)
        cls_init.chol_pol_covar = pol_dict['chol_pol_covar']
        cls_init.scale = pol_dict['scale']
        cls_init.bias = pol_dict['bias']
        cls_init.x_idx = pol_dict['x_idx']
        return cls_init
def load_policy ( cls , policy_dict_path , tf_generator , network_config = None ) : from tensorflow . python . framework import ops ops . reset_default_graph ( ) # we need to destroy the default graph before re_init or checkpoint won't restore. pol_dict = pickle . load ( open ( policy_dict_path , "rb" ) ) tf_map = tf_generator ( dim_input = pol_dict [ 'deg_obs' ] , dim_output = pol_dict [ 'deg_action' ] , batch_size = 1 , network_config = network_config ) sess = tf . Session ( ) init_op = tf . initialize_all_variables ( ) sess . run ( init_op ) saver = tf . train . Saver ( ) check_file = pol_dict [ 'checkpoint_path_tf' ] saver . restore ( sess , check_file ) device_string = pol_dict [ 'device_string' ] cls_init = cls ( pol_dict [ 'deg_action' ] , tf_map . get_input_tensor ( ) , tf_map . get_output_op ( ) , np . zeros ( ( 1 , ) ) , sess , device_string ) cls_init . chol_pol_covar = pol_dict [ 'chol_pol_covar' ] cls_init . scale = pol_dict [ 'scale' ] cls_init . bias = pol_dict [ 'bias' ] cls_init . x_idx = pol_dict [ 'x_idx' ] return cls_init