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: 7

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: idaholab/raven
Commit Name: 5ad7296f10444d96a15e34dc1b040ca1b8f947cc
Time: 2017-08-11
Author: paul.talbot@inl.gov
File Name: framework/Optimizers/Optimizer.py
Class Name: Optimizer
Method Name: updateMultilevelDepth


Project Name: albu/albumentations
Commit Name: 9942689f9846c59006c80718ee8db38e02ee2104
Time: 2019-09-27
Author: al.buslaev@gmail.com
File Name: albumentations/core/transforms_interface.py
Class Name: BasicTransform
Method Name: __call__