import tensorflow as tf

        old_action_op, old_action_op_params = self._build_anet(
            'old_action_op', trainable=False)

        # 定義輸出範例
        self.sample_op = tf.squeeze(
            action_op.sample(1),
            axis=0)  # operation of choosing action
        # 更新
        self.update_old_action_op_op = [
            olda.assign(a) for a, olda in zip(
                action_op_params, old_action_op_params)]
        # 定義輸入變數
        self.tfa = tf.placeholder(tf.float32, [None, action_dim], 'action')
        self.tfadv = tf.placeholder(tf.float32, [None, 1], 'advantage')
        # 機率比較
        ratio = action_op.prob(self.tfa) / \
            (old_action_op.prob(self.tfa) + 1e-5)
        # 替代損失
        surr = ratio * self.tfadv
        # 減少代理損失
        self.aloss = -tf.reduce_mean(tf.minimum(
            surr,
            tf.clip_by_value(ratio, 1. - EPSILON, 1. + EPSILON) * self.tfadv))
        self.atrain_op = tf.train.AdamOptimizer(A_LR).minimize(self.aloss)
        # log
        self.train_writer = tf.summary.FileWriter("logs/", self.sess.graph)
