98f57a0d8781083cbca137fb9d84313b94d9d108,agents/ddpg_agent.py,DDPGAgent,choose_action,#DDPGAgent#Any#Any#,84

Before Change


    def choose_action(self, curr_state, phase=RunPhase.TRAIN):
        assert not self.env.discrete_controls, "DDPG works only for continuous control problems"
        // convert to batch so we can run it through the network
        observation = np.expand_dims(np.array(curr_state["observation"]), 0)
        result = self.actor_network.online_network.predict(observation)
        action_values = result[0].squeeze()

After Change



    def choose_action(self, curr_state, phase=RunPhase.TRAIN):
        assert not self.env.discrete_controls, "DDPG works only for continuous control problems"
        result = self.actor_network.online_network.predict(self.tf_input_state(curr_state))
        action_values = result[0].squeeze()

        if phase == RunPhase.TRAIN:
            action = self.exploration_policy.get_action(action_values)
        else:
            action = action_values

        action = np.clip(action, self.env.action_space_low, self.env.action_space_high)

        // get q value
        action_batch = np.expand_dims(action, 0)
        if type(action) != np.ndarray:
            action_batch = np.array([[action]])
        inputs = self.tf_input_state(curr_state)
        inputs["action"] = action_batch
        q_value = self.critic_network.online_network.predict(inputs)[0]
        self.q_values.add_sample(q_value)
        action_info = {"action_value": q_value}
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 3

Instances


Project Name: NervanaSystems/coach
Commit Name: 98f57a0d8781083cbca137fb9d84313b94d9d108
Time: 2018-02-21
Author: zach.dwiel@intel.com
File Name: agents/ddpg_agent.py
Class Name: DDPGAgent
Method Name: choose_action


Project Name: NervanaSystems/coach
Commit Name: 39a28aba95b0d8eeb56f7a17b7dad140e601b591
Time: 2018-02-21
Author: zach.dwiel@intel.com
File Name: agents/clipped_ppo_agent.py
Class Name: ClippedPPOAgent
Method Name: choose_action


Project Name: NervanaSystems/coach
Commit Name: 8248caf35eeb43046f2b28937627d43cbf950c9a
Time: 2018-02-21
Author: zach.dwiel@intel.com
File Name: agents/policy_gradients_agent.py
Class Name: PolicyGradientsAgent
Method Name: choose_action


Project Name: NervanaSystems/coach
Commit Name: 8248caf35eeb43046f2b28937627d43cbf950c9a
Time: 2018-02-21
Author: zach.dwiel@intel.com
File Name: agents/ppo_agent.py
Class Name: PPOAgent
Method Name: choose_action


Project Name: NervanaSystems/coach
Commit Name: 98f57a0d8781083cbca137fb9d84313b94d9d108
Time: 2018-02-21
Author: zach.dwiel@intel.com
File Name: agents/ddpg_agent.py
Class Name: DDPGAgent
Method Name: choose_action