535ca090eb4d780169494c1c17eaaba8005bcecc,catalyst/rl/offpolicy/exploration/exploration.py,ExplorationHandler,__init__,#ExplorationHandler#,7

Before Change


    def __init__(self, **params):
        from catalyst.contrib.registry import Registry

        config_ = params.copy()
        self.strategies: List[ExplorationStrategy] = []
        self.probs = []

        for key, expl in config_.items():
            probability = expl["probability"]
            expl_params = expl["params"] or {}
            strategy = Registry.get_exploration(
                strategy=expl["strategy"], **expl_params)
            self.strategies.append(strategy)
            self.probs.append(probability)

        self.num_strategies = len(self.probs)

    def get_exploration_strategy(self):
        strategy_idx = np.random.choice(self.num_strategies, p=self.probs)

After Change



class ExplorationHandler:
    def __init__(self, *exploration_params, env: EnvironmentSpec):
        params = deepcopy(exploration_params)
        self.exploration_strategies: List[ExplorationStrategy] = []
        self.probs = []

        for params_ in params:
            exploration_name = params_.pop("exploration")
            probability = params_.pop("probability")
            strategy_fn = EXPLORATION.get(exploration_name)

            if issubclass(strategy_fn, EpsilonGreedy):
                assert isinstance(env.action_space, Discrete)
                params_["num_actions"] = env.action_space.n

            strategy = strategy_fn(**params_)
            self.exploration_strategies.append(strategy)
            self.probs.append(probability)

        self.num_strategies = len(self.probs)
        assert np.isclose(np.sum(self.probs), 1.0)

    def get_exploration_strategy(self):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: Scitator/catalyst
Commit Name: 535ca090eb4d780169494c1c17eaaba8005bcecc
Time: 2019-04-14
Author: scitator@gmail.com
File Name: catalyst/rl/offpolicy/exploration/exploration.py
Class Name: ExplorationHandler
Method Name: __init__


Project Name: pantsbuild/pants
Commit Name: 30dda3a132d6d74bed81fd51144a7247d02cea9a
Time: 2015-11-30
Author: zundel@squareup.com
File Name: src/python/pants/backend/core/tasks/reflect.py
Class Name:
Method Name: gen_tasks_options_reference_data


Project Name: Featuretools/featuretools
Commit Name: 0739b88a26f23de29971ddeae193ff3eed06c848
Time: 2019-05-03
Author: rwedge@featurelabs.com
File Name: featuretools/primitives/__init__.py
Class Name:
Method Name: