2f8f6892d7d7787171d68c01267ab4ed98bf0f31,ml/rl/test/gridworld/gridworld_base.py,GridworldBase,sample_policy,#GridworldBase#Any#Any#,283

Before Change


            if len(possible_actions) == 1:
                return possible_actions[0], 1.0
            else:
                return (
                    np.random.choice(possible_actions),
                    epsilon / (len(possible_actions) - 1),
                )
        else:
            return self.optimal_policy(state), (1.0 - epsilon)

    @property

After Change


            return "", 1.0
        optimal_action = self.optimal_policy(state)
        if np.random.rand() < epsilon:
            action = np.random.choice(possible_actions)
        else:
            action = optimal_action
        if action == optimal_action:
            action_probability = (1.0 - epsilon) + epsilon / len(possible_actions)
        else:
            action_probability = epsilon / len(possible_actions)
        return action, action_probability

    @property
    def num_actions(self):
        return len(self.ACTIONS)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: facebookresearch/Horizon
Commit Name: 2f8f6892d7d7787171d68c01267ab4ed98bf0f31
Time: 2018-09-25
Author: yitaoliang@fb.com
File Name: ml/rl/test/gridworld/gridworld_base.py
Class Name: GridworldBase
Method Name: sample_policy


Project Name: NervanaSystems/coach
Commit Name: 9e9c4fd3322b6e8f47572fefdb8fd65018fb96f7
Time: 2019-05-27
Author: gal.leibovich@intel.com
File Name: rl_coach/exploration_policies/boltzmann.py
Class Name: Boltzmann
Method Name: get_action


Project Name: NervanaSystems/coach
Commit Name: 9e9c4fd3322b6e8f47572fefdb8fd65018fb96f7
Time: 2019-05-27
Author: gal.leibovich@intel.com
File Name: rl_coach/exploration_policies/categorical.py
Class Name: Categorical
Method Name: get_action