id
int64
0
328k
repository_name
stringlengths
7
58
file_path
stringlengths
9
302
class_name
stringlengths
5
256
human_written_code
stringlengths
16
2.16M
class_skeleton
stringlengths
18
1.49M
⌀
total_program_units
int64
1
1.76k
total_doc_str
int64
0
771
AvgCountLine
float64
0
7.89k
AvgCountLineBlank
float64
0
297
AvgCountLineCode
float64
0
7.89k
AvgCountLineComment
float64
0
7.89k
AvgCyclomatic
float64
0
130
CommentToCodeRatio
float64
0
168
CountClassBase
float64
0
40
CountClassCoupled
float64
0
583
CountClassCoupledModified
float64
0
575
CountClassDerived
float64
0
5.35k
CountDeclInstanceMethod
float64
0
529
CountDeclInstanceVariable
float64
0
296
CountDeclMethod
float64
0
599
CountDeclMethodAll
float64
0
1.12k
CountLine
float64
1
40.4k
CountLineBlank
float64
0
8.16k
CountLineCode
float64
1
25.7k
CountLineCodeDecl
float64
1
8.15k
CountLineCodeExe
float64
0
24.2k
CountLineComment
float64
0
16.5k
CountStmt
float64
1
9.71k
CountStmtDecl
float64
1
8.15k
CountStmtExe
float64
0
9.69k
MaxCyclomatic
float64
0
759
MaxInheritanceTree
float64
0
16
MaxNesting
float64
0
34
SumCyclomatic
float64
0
2.9k
11,200
ray-project/ray
rllib/algorithms/impala/impala_torch_policy.py
rllib.algorithms.impala.impala_torch_policy.ImpalaTorchPolicy
from typing import Dict, List, Optional, Type, Union from ray.rllib.policy.torch_policy_v2 import TorchPolicyV2 from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.numpy import convert_to_numpy from ray.rllib.utils.torch_utils import apply_grad_clipping, explained_variance, global_norm, sequence_...
class ImpalaTorchPolicy(VTraceOptimizer, LearningRateSchedule, EntropyCoeffSchedule, ValueNetworkMixin, TorchPolicyV2): '''PyTorch policy class used with IMPALA.''' def __init__(self, observation_space, action_space, config): pass @override(TorchPolicyV2) def loss(self, model: ModelV2, dist_cl...
13
1
26
2
22
2
2
0.1
5
6
1
0
6
2
6
8
200
21
162
55
131
17
67
30
59
8
1
1
17
11,201
ray-project/ray
rllib/algorithms/impala/impala_torch_policy.py
rllib.algorithms.impala.impala_torch_policy.VTraceLoss
class VTraceLoss: def __init__(self, actions, actions_logp, actions_entropy, dones, behaviour_action_logp, behaviour_logits, target_logits, discount, rewards, values, bootstrap_value, dist_class, model, valid_mask, config, vf_loss_coeff=0.5, entropy_coeff=0.01, clip_rho_threshold=1.0, clip_pg_rho_threshold=1.0): ...
class VTraceLoss: def __init__(self, actions, actions_logp, actions_entropy, dones, behaviour_action_logp, behaviour_logits, target_logits, discount, rewards, values, bootstrap_value, dist_class, model, valid_mask, config, vf_loss_coeff=0.5, entropy_coeff=0.01, clip_rho_threshold=1.0, clip_pg_rho_threshold=1.0): ...
2
1
98
9
52
37
3
0.7
0
0
0
0
1
8
1
1
99
9
53
34
29
37
17
13
14
3
0
1
3
11,202
ray-project/ray
rllib/algorithms/impala/impala_torch_policy.py
rllib.algorithms.impala.impala_torch_policy.VTraceOptimizer
from typing import Dict, List, Optional, Type, Union class VTraceOptimizer: """Optimizer function for VTrace torch policies.""" def __init__(self): pass def optimizer(self) -> Union[List['torch.optim.Optimizer'], 'torch.optim.Optimizer']: if self.config['_separate_vf_optimizer']: ...
class VTraceOptimizer: '''Optimizer function for VTrace torch policies.''' def __init__(self): pass def optimizer(self) -> Union[List['torch.optim.Optimizer'], 'torch.optim.Optimizer']: pass
3
1
24
1
19
5
4
0.29
0
1
0
1
2
1
2
2
52
4
38
11
33
11
22
8
19
7
0
3
8
11,203
ray-project/ray
rllib/algorithms/impala/torch/impala_torch_learner.py
rllib.algorithms.impala.torch.impala_torch_learner.IMPALATorchLearner
from ray.rllib.algorithms.impala.impala import IMPALAConfig from ray.rllib.core.learner.torch.torch_learner import TorchLearner from ray.rllib.utils.typing import ModuleID, TensorType from ray.rllib.algorithms.impala.impala_learner import IMPALALearner from ray.rllib.algorithms.impala.torch.vtrace_torch_v2 import vtrac...
class IMPALATorchLearner(IMPALALearner, TorchLearner): '''Implements the IMPALA loss function in torch.''' @override(TorchLearner) def compute_loss_for_module(self, *, module_id: ModuleID, config: IMPALAConfig, batch: Dict, fwd_out: Dict[str, TensorType]) -> TensorType: pass
3
1
139
12
103
27
1
0.27
2
2
0
0
1
0
1
1
143
13
105
35
95
28
30
27
28
1
1
0
1
11,204
ray-project/ray
rllib/algorithms/impala/utils.py
rllib.algorithms.impala.utils._SleepTimeController
from collections import defaultdict, deque import numpy as np class _SleepTimeController: def __init__(self): self.L = 0.0 self.H = 0.4 self._recompute_candidates() self.results = defaultdict(lambda: deque(maxlen=3)) self.iteration = 0 def _recompute_candidates(self): ...
class _SleepTimeController: def __init__(self): pass def _recompute_candidates(self): pass @property def current(self): pass def log_result(self, performance): pass
6
0
20
2
15
3
3
0.22
0
0
0
0
4
7
4
4
84
11
60
18
54
13
47
17
42
5
0
2
11
11,205
ray-project/ray
rllib/algorithms/marwil/marwil.py
rllib.algorithms.marwil.marwil.MARWIL
from ray.rllib.policy.policy import Policy from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided from ray.rllib.execution.rollout_ops import synchronous_parallel_sample from ray.rllib.utils.typing import EnvType, ResultDict, RLModule...
class MARWIL(Algorithm): @classmethod @override(Algorithm) def get_default_config(cls) -> MARWILConfig: pass @classmethod @override(Algorithm) def get_default_policy_class(cls, config: AlgorithmConfig) -> Optional[Type[Policy]]: pass @override(Algorithm) def training_st...
11
2
26
4
15
8
3
0.47
1
2
1
0
2
0
4
4
114
17
66
23
46
31
34
13
26
3
1
2
10
11,206
ray-project/ray
rllib/algorithms/marwil/marwil.py
rllib.algorithms.marwil.marwil.MARWILConfig
from ray.rllib.utils.typing import EnvType, ResultDict, RLModuleSpecType from ray.rllib.utils.annotations import OldAPIStack, override from typing_extensions import Self from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided from ray.rllib.connectors.learner import AddObservationsFromEpisodesToB...
class MARWILConfig(AlgorithmConfig): '''Defines a configuration class from which a MARWIL Algorithm can be built. .. testcode:: import gymnasium as gym import numpy as np from pathlib import Path from ray.rllib.algorithms.marwil import MARWILConfig # Get the base path (t...
20
4
24
2
15
7
3
1.08
1
5
1
0
10
16
10
10
375
44
159
66
110
172
78
30
64
7
1
2
26
11,207
ray-project/ray
rllib/algorithms/marwil/marwil_learner.py
rllib.algorithms.marwil.marwil_learner.MARWILLearner
from ray.rllib.core.learner.learner import Learner from ray.rllib.utils.typing import ModuleID, ShouldModuleBeUpdatedFn, TensorType from typing import Dict, Optional from ray.rllib.core.rl_module.apis import ValueFunctionAPI from ray.rllib.utils.lambda_defaultdict import LambdaDefaultDict from ray.rllib.utils.annotatio...
class MARWILLearner(Learner): @override(Learner) def build(self) -> None: pass @override(Learner) def remove_module(self, module_id: ModuleID, *, new_should_module_be_updated: Optional[ShouldModuleBeUpdatedFn]=None) -> None: pass @classmethod @override(Learner) def rl_modul...
8
0
10
0
8
2
1
0.17
1
3
0
0
2
1
3
3
37
3
29
13
16
5
9
5
5
1
1
0
3
11,208
ray-project/ray
rllib/algorithms/marwil/marwil_tf_policy.py
rllib.algorithms.marwil.marwil_tf_policy.MARWILLoss
from ray.rllib.utils.typing import LocalOptimizer, ModelGradients, TensorType from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.tf_utils import explained_variance from ray.rllib.policy.policy import Policy from ray.rllib.evaluation.pos...
class MARWILLoss: def __init__(self, policy: Policy, value_estimates: TensorType, action_dist: ActionDistribution, train_batch: SampleBatch, vf_loss_coeff: float, beta: float): pass
2
0
74
9
50
15
4
0.29
0
1
0
0
1
4
1
1
75
9
51
25
41
15
27
17
25
4
0
3
4
11,209
ray-project/ray
rllib/algorithms/marwil/marwil_tf_policy.py
rllib.algorithms.marwil.marwil_tf_policy.PostprocessAdvantages
from ray.rllib.evaluation.postprocessing import compute_advantages, Postprocessing from typing import Any, Dict, List, Optional, Type, Union from ray.rllib.policy.sample_batch import SampleBatch class PostprocessAdvantages: """Marwil's custom trajectory post-processing mixin.""" def __init__(self): pa...
class PostprocessAdvantages: '''Marwil's custom trajectory post-processing mixin.''' def __init__(self): pass def postprocess_trajectory(self, sample_batch: SampleBatch, other_agent_batches: Optional[Dict[Any, SampleBatch]]=None, episode=None): pass
3
1
19
1
13
5
2
0.41
0
2
0
1
2
1
2
2
42
4
27
12
19
11
11
6
8
3
0
1
4
11,210
ray-project/ray
rllib/algorithms/marwil/marwil_torch_policy.py
rllib.algorithms.marwil.marwil_torch_policy.MARWILTorchPolicy
from typing import Dict, List, Type, Union from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.utils.typing import TensorType from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.models.torch.torch_action_dist import TorchDistributionWrapper from ray.rllib.utils.annotations import override from ...
class MARWILTorchPolicy(ValueNetworkMixin, PostprocessAdvantages, TorchPolicyV2): '''PyTorch policy class used with Marwil.''' def __init__(self, observation_space, action_space, config): pass @override(TorchPolicyV2) def loss(self, model: ModelV2, dist_class: Type[TorchDistributionWrapper], t...
7
1
27
2
21
4
2
0.21
3
1
0
0
4
3
4
4
114
11
85
35
71
18
49
26
44
3
1
1
8
11,211
ray-project/ray
rllib/algorithms/marwil/torch/marwil_torch_learner.py
rllib.algorithms.marwil.torch.marwil_torch_learner.MARWILTorchLearner
from ray.rllib.core.learner.learner import POLICY_LOSS_KEY, VF_LOSS_KEY from ray.rllib.core.learner.torch.torch_learner import TorchLearner from typing import Any, Dict, Optional from ray.rllib.algorithms.marwil.marwil import MARWILConfig from ray.rllib.utils.torch_utils import explained_variance from ray.rllib.core.co...
class MARWILTorchLearner(MARWILLearner, TorchLearner): '''Implements torch-specific MARWIL loss on top of MARWILLearner. This class implements the MARWIL loss under `self.compute_loss_for_module()`. ''' def compute_loss_for_module(self, *, module_id: str, config: Optional[MARWILConfig]=None, batch...
3
1
59
7
40
13
3
0.37
2
2
0
0
1
0
1
1
121
15
78
24
68
29
30
17
27
5
1
1
6
11,212
ray-project/ray
rllib/algorithms/mock.py
rllib.algorithms.mock._MockTrainer
import os import pickle import time from ray.rllib.algorithms.algorithm import Algorithm, AlgorithmConfig from ray.tune import result as tune_result from ray.rllib.utils.annotations import override class _MockTrainer(Algorithm): """Mock Algorithm for use in tests.""" @classmethod @override(Algorithm) ...
class _MockTrainer(Algorithm): '''Mock Algorithm for use in tests.''' @classmethod @override(Algorithm) def get_default_config(cls) -> AlgorithmConfig: pass @classmethod def default_resource_request(cls, config: AlgorithmConfig): pass @override(Algorithm) def setup(self,...
19
1
6
0
6
0
1
0.05
1
2
0
2
6
3
9
9
76
10
63
26
44
3
36
17
26
5
1
2
13
11,213
ray-project/ray
rllib/algorithms/mock.py
rllib.algorithms.mock._ParameterTuningTrainer
from ray.rllib.utils.annotations import override from ray.rllib.algorithms.algorithm import Algorithm, AlgorithmConfig class _ParameterTuningTrainer(_MockTrainer): @classmethod @override(Algorithm) def get_default_config(cls) -> AlgorithmConfig: return AlgorithmConfig().update_from_dict({'reward_a...
class _ParameterTuningTrainer(_MockTrainer): @classmethod @override(Algorithm) def get_default_config(cls) -> AlgorithmConfig: pass def step(self): pass
5
0
9
0
9
0
1
0
1
1
0
0
1
1
2
11
22
1
21
5
16
0
5
3
2
1
2
0
2
11,214
ray-project/ray
rllib/algorithms/mock.py
rllib.algorithms.mock._SigmoidFakeData
from ray.rllib.utils.annotations import override from ray.rllib.algorithms.algorithm import Algorithm, AlgorithmConfig import numpy as np class _SigmoidFakeData(_MockTrainer): """Algorithm that returns sigmoid learning curves. This can be helpful for evaluating early stopping algorithms.""" @classmethod ...
class _SigmoidFakeData(_MockTrainer): '''Algorithm that returns sigmoid learning curves. This can be helpful for evaluating early stopping algorithms.''' @classmethod @override(Algorithm) def get_default_config(cls) -> AlgorithmConfig: pass def step(self): pass
5
1
11
0
11
0
1
0.08
1
2
0
0
1
0
2
11
29
3
24
6
19
2
8
5
5
1
2
0
2
11,215
ray-project/ray
rllib/algorithms/ppo/default_ppo_rl_module.py
rllib.algorithms.ppo.default_ppo_rl_module.DefaultPPORLModule
from ray.util.annotations import DeveloperAPI import abc from ray.rllib.core.models.configs import RecurrentEncoderConfig from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic_CallToSuperRecommended from ray.rllib.core.rl_module.apis import InferenceOnlyAPI, ValueFunctionAPI from ray.rllib.co...
@DeveloperAPI class DefaultPPORLModule(RLModule, InferenceOnlyAPI, ValueFunctionAPI, abc.ABC): '''Default RLModule used by PPO, if user does not specify a custom RLModule. Users who want to train their RLModules with PPO may implement any RLModule (or TorchRLModule) subclass as long as the custom class also...
9
2
11
0
8
3
2
0.54
4
2
0
0
3
4
3
23
48
5
28
12
20
15
16
9
12
3
4
1
7
11,216
ray-project/ray
rllib/algorithms/ppo/ppo.py
rllib.algorithms.ppo.ppo.PPO
from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.algorithms.algorithm import Algorithm from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided from ray.rllib.execution.train_ops import train_one_step, multi_gpu_train_one_step from ray.rllib.execution.rollout_ops import...
class PPO(Algorithm): @classmethod @override(Algorithm) def get_default_config(cls) -> PPOConfig: pass @classmethod @override(Algorithm) def get_default_policy_class(cls, config: AlgorithmConfig) -> Optional[Type[Policy]]: pass @override(Algorithm) def training_step(sel...
11
0
47
4
35
8
4
0.23
1
3
1
0
2
3
4
4
198
19
146
30
130
33
61
22
53
8
1
2
16
11,217
ray-project/ray
rllib/algorithms/ppo/ppo.py
rllib.algorithms.ppo.ppo.PPOConfig
from typing import Any, Dict, List, Optional, Type, Union, TYPE_CHECKING from typing_extensions import Self from ray.rllib.core.rl_module.rl_module import RLModuleSpec from ray.rllib.utils.schedules.scheduler import Scheduler from ray._common.deprecation import DEPRECATED_VALUE from ray.rllib.algorithms.algorithm_confi...
class PPOConfig(AlgorithmConfig): '''Defines a configuration class from which a PPO Algorithm can be built. .. testcode:: from ray.rllib.algorithms.ppo import PPOConfig config = PPOConfig() config.environment("CartPole-v1") config.env_runners(num_env_runners=1) config.tr...
13
3
41
3
26
12
5
0.65
1
8
1
0
6
24
6
6
300
33
164
62
127
106
88
34
79
14
1
2
30
11,218
ray-project/ray
rllib/algorithms/ppo/ppo_catalog.py
rllib.algorithms.ppo.ppo_catalog.PPOCatalog
from ray.rllib.core.models.catalog import Catalog from ray.rllib.core.models.configs import ActorCriticEncoderConfig, MLPHeadConfig, FreeLogStdMLPHeadConfig from ray.rllib.utils import override from ray.rllib.core.models.base import Encoder, ActorCriticEncoder, Model from ray.rllib.utils.annotations import OverrideToIm...
class PPOCatalog(Catalog): '''The Catalog class used to build models for PPO. PPOCatalog provides the following models: - ActorCriticEncoder: The encoder used to encode the observations. - Pi Head: The head used to compute the policy logits. - Value Function Head: The head used to compu...
10
6
25
3
13
9
1
0.9
1
4
0
0
5
8
5
5
160
25
71
27
56
64
24
15
18
3
1
1
7
11,219
ray-project/ray
rllib/algorithms/ppo/ppo_learner.py
rllib.algorithms.ppo.ppo_learner.PPOLearner
from ray.rllib.utils.metrics import NUM_ENV_STEPS_SAMPLED_LIFETIME, NUM_MODULE_STEPS_TRAINED from ray.rllib.utils.schedules.scheduler import Scheduler from ray.rllib.core.rl_module.apis.value_function_api import ValueFunctionAPI from ray.rllib.utils.lambda_defaultdict import LambdaDefaultDict from ray.rllib.algorithms....
class PPOLearner(Learner): @override(Learner) def build(self) -> None: pass @override(Learner) def remove_module(self, module_id: ModuleID, **kwargs): pass @OverrideToImplementCustomLogic_CallToSuperRecommended @override(Learner) def after_gradient_based_update(self, *, tim...
13
1
22
2
14
6
2
0.35
1
6
0
0
4
2
5
5
121
13
80
28
57
28
25
13
19
3
1
2
8
11,220
ray-project/ray
rllib/algorithms/ppo/ppo_torch_policy.py
rllib.algorithms.ppo.ppo_torch_policy.PPOTorchPolicy
from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.policy.torch_mixins import EntropyCoeffSchedule, KLCoeffMixin, LearningRateSchedule, ValueNetworkMixin from ray.rllib.utils.typing import TensorType from ray.rllib.evaluation.postprocessing import Postprocessing, compute_gae_for_sample_batch import ray from ra...
class PPOTorchPolicy(ValueNetworkMixin, LearningRateSchedule, EntropyCoeffSchedule, KLCoeffMixin, TorchPolicyV2): '''PyTorch policy class used with PPO.''' def __init__(self, observation_space, action_space, config): pass @override(TorchPolicyV2) def loss(self, model: ModelV2, dist_class: Type...
11
2
28
3
21
4
2
0.2
5
2
0
0
5
0
5
5
182
24
132
42
108
26
57
25
50
5
1
1
10
11,221
ray-project/ray
rllib/algorithms/ppo/torch/default_ppo_torch_rl_module.py
rllib.algorithms.ppo.torch.default_ppo_torch_rl_module.DefaultPPOTorchRLModule
from ray.rllib.algorithms.ppo.ppo_catalog import PPOCatalog from ray.rllib.core.rl_module.apis.value_function_api import ValueFunctionAPI from ray.rllib.core.rl_module.torch import TorchRLModule from ray.util.annotations import DeveloperAPI from ray.rllib.utils.typing import TensorType from typing import Any, Dict, Opt...
null
9
2
12
0
9
3
3
0.28
2
3
0
0
4
0
4
4
55
4
40
19
28
11
32
12
27
4
1
3
10
11,222
ray-project/ray
rllib/algorithms/ppo/torch/ppo_torch_learner.py
rllib.algorithms.ppo.torch.ppo_torch_learner.PPOTorchLearner
from ray.rllib.evaluation.postprocessing import Postprocessing from ray.rllib.algorithms.ppo.ppo import LEARNER_RESULTS_KL_KEY, LEARNER_RESULTS_CURR_KL_COEFF_KEY, LEARNER_RESULTS_VF_EXPLAINED_VAR_KEY, LEARNER_RESULTS_VF_LOSS_UNCLIPPED_KEY, PPOConfig from ray.rllib.core.learner.torch.torch_learner import TorchLearner fr...
class PPOTorchLearner(PPOLearner, TorchLearner): '''Implements torch-specific PPO loss logic on top of PPOLearner. This class implements the ppo loss under `self.compute_loss_for_module()`. ''' @override(TorchLearner) def compute_loss_for_module(self, *, module_id: ModuleID, config: PPOConfig, ...
6
1
46
5
35
7
3
0.22
2
3
0
0
2
0
2
2
146
18
106
40
87
23
42
25
38
5
1
1
10
11,223
ray-project/ray
rllib/algorithms/sac/default_sac_rl_module.py
rllib.algorithms.sac.default_sac_rl_module.DefaultSACRLModule
from ray.rllib.core.rl_module.apis import InferenceOnlyAPI, QNetAPI, TargetNetworkAPI from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic from ray.util.annotations import DeveloperAPI from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.core.models.base import Encoder, Mod...
@DeveloperAPI class DefaultSACRLModule(RLModule, InferenceOnlyAPI, TargetNetworkAPI, QNetAPI): '''`RLModule` for the Soft-Actor-Critic (SAC) algorithm. It consists of several architectures, each in turn composed of two networks: an encoder and a head. The policy (actor) contains a state encoder (`pi_enc...
15
3
12
1
8
3
2
0.72
4
3
0
0
8
11
8
8
146
19
74
31
54
53
33
21
24
5
1
2
16
11,224
ray-project/ray
rllib/algorithms/sac/sac.py
rllib.algorithms.sac.sac.SAC
from ray.rllib.policy.policy import Policy from ray.rllib.utils.annotations import override from typing import Any, Dict, Optional, Tuple, Type, Union from ray.rllib.algorithms.sac.sac_tf_policy import SACTFPolicy from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided from ray.rllib.algorithms.d...
class SAC(DQN): '''Soft Actor Critic (SAC) Algorithm class. This file defines the distributed Algorithm class for the soft actor critic algorithm. See `sac_[tf|torch]_policy.py` for the definition of the policy loss. Detailed documentation: https://docs.ray.io/en/master/rllib-algorithms.html#sa...
8
1
5
0
4
0
1
0.39
1
2
1
0
1
0
3
3
31
6
18
9
7
7
11
5
6
2
1
1
4
11,225
ray-project/ray
rllib/algorithms/sac/sac.py
rllib.algorithms.sac.sac.SACConfig
from typing_extensions import Self from ray._common.deprecation import DEPRECATED_VALUE, deprecation_warning from typing import Any, Dict, Optional, Tuple, Type, Union from ray.rllib.utils import deep_update from ray.rllib.core.rl_module.rl_module import RLModuleSpec from ray.rllib.connectors.common.add_observations_fr...
class SACConfig(AlgorithmConfig): '''Defines a configuration class from which an SAC Algorithm can be built. .. testcode:: config = ( SACConfig() .environment("Pendulum-v1") .env_runners(num_env_runners=1) .training( gamma=0.9, ...
16
2
61
3
34
25
5
0.77
1
11
1
0
8
30
8
8
526
34
281
82
232
216
118
43
107
21
1
2
42
11,226
ray-project/ray
rllib/algorithms/sac/sac_catalog.py
rllib.algorithms.sac.sac_catalog.SACCatalog
import gymnasium as gym from ray.rllib.core.distribution.torch.torch_distribution import TorchSquashedGaussian, TorchCategorical from ray.rllib.core.distribution.distribution import Distribution from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic from typing import Callable import numpy as ...
class SACCatalog(Catalog): '''The catalog class used to build models for SAC. SACCatalog provides the following models: - Encoder: The encoder used to encode the observations for the actor network (`pi`). For this we use the default encoder from the Catalog. - Q-Function Encoder: Th...
13
9
30
4
18
9
2
0.72
1
4
0
0
5
9
5
5
188
28
93
31
77
67
32
19
26
3
1
1
8
11,227
ray-project/ray
rllib/algorithms/sac/sac_learner.py
rllib.algorithms.sac.sac_learner.SACLearner
from ray.rllib.utils.lambda_defaultdict import LambdaDefaultDict from ray.rllib.utils.typing import ModuleID, TensorType from ray.rllib.utils.annotations import override import numpy as np from ray.rllib.core.learner.learner import Learner from ray.rllib.algorithms.dqn.dqn_learner import DQNLearner from typing import D...
class SACLearner(DQNLearner): @override(Learner) def build(self) -> None: pass @override(Learner) def remove_module(self, module_id: ModuleID) -> None: '''Removes the temperature and target entropy. Note, this means that we also need to remove the corresponding temperat...
8
2
21
3
11
8
1
0.55
1
1
0
0
2
2
2
2
52
7
29
9
23
16
14
7
10
2
1
1
4
11,228
ray-project/ray
rllib/algorithms/sac/sac_tf_model.py
rllib.algorithms.sac.sac_tf_model.SACTFModel
from ray.rllib.utils.spaces.simplex import Simplex import gymnasium as gym import tree from ray.rllib.models.tf.tf_modelv2 import TFModelV2 from gymnasium.spaces import Box, Discrete import numpy as np from ray.rllib.utils.typing import ModelConfigDict, TensorType, TensorStructType from ray.rllib.models.catalog import ...
class SACTFModel(TFModelV2): '''Extension of the standard TFModelV2 for SAC. To customize, do one of the following: - sub-class SACTFModel and override one or more of its methods. - Use SAC's `q_model_config` and `policy_model` keys to tweak the default model behaviors (e.g. fcnet_hiddens, conv_f...
13
11
26
3
15
8
3
0.7
1
8
0
0
10
10
10
10
305
41
155
55
116
109
79
27
67
6
1
2
31
11,229
ray-project/ray
rllib/algorithms/sac/sac_tf_policy.py
rllib.algorithms.sac.sac_tf_policy.ActorCriticOptimizerMixin
from ray.rllib.utils.framework import get_variable, try_import_tf class ActorCriticOptimizerMixin: """Mixin class to generate the necessary optimizers for actor-critic algos. - Creates global step for counting the number of update operations. - Creates separate optimizers for actor, critic, and alpha. ...
class ActorCriticOptimizerMixin: '''Mixin class to generate the necessary optimizers for actor-critic algos. - Creates global step for counting the number of update operations. - Creates separate optimizers for actor, critic, and alpha. ''' def __init__(self, config): pass
2
1
41
0
39
2
4
0.15
0
0
0
0
1
4
1
1
48
2
40
6
38
6
15
6
13
4
0
2
4
11,230
ray-project/ray
rllib/algorithms/sac/sac_tf_policy.py
rllib.algorithms.sac.sac_tf_policy.ComputeTDErrorMixin
from ray.rllib.algorithms.dqn.dqn_tf_policy import postprocess_nstep_and_prio, PRIO_WEIGHTS from ray.rllib.utils.tf_utils import huber_loss, make_tf_callable from ray.rllib.policy.sample_batch import SampleBatch class ComputeTDErrorMixin: def __init__(self, loss_fn): @make_tf_callable(self.get_session(),...
class ComputeTDErrorMixin: def __init__(self, loss_fn): pass @make_tf_callable(self.get_session(), dynamic_shape=True) def compute_td_error(obs_t, act_t, rew_t, obs_tp1, terminateds_mask, importance_weights): pass
4
0
22
1
19
3
1
0.14
0
0
0
0
1
1
1
1
25
1
21
7
15
3
6
4
3
1
0
0
2
11,231
ray-project/ray
rllib/algorithms/sac/sac_torch_model.py
rllib.algorithms.sac.sac_torch_model.SACTorchModel
from ray.rllib.models.catalog import ModelCatalog import tree from ray.rllib.utils.annotations import override import gymnasium as gym from typing import Dict, List, Optional from ray.rllib.utils.spaces.simplex import Simplex import numpy as np from gymnasium.spaces import Box, Discrete from ray.rllib.models.torch.torc...
class SACTorchModel(TorchModelV2, nn.Module): '''Extension of the standard TorchModelV2 for SAC. To customize, do one of the following: - sub-class SACTorchModel and override one or more of its methods. - Use SAC's `q_model_config` and `policy_model` keys to tweak the default model behaviors (e.g...
13
11
27
3
15
9
3
0.7
2
8
0
0
10
7
10
10
313
42
159
53
120
112
81
25
69
6
1
2
31
11,232
ray-project/ray
rllib/algorithms/sac/sac_torch_policy.py
rllib.algorithms.sac.sac_torch_policy.ComputeTDErrorMixin
from ray.rllib.algorithms.dqn.dqn_tf_policy import PRIO_WEIGHTS from ray.rllib.policy.sample_batch import SampleBatch class ComputeTDErrorMixin: """Mixin class calculating TD-error (part of critic loss) per batch item. - Adds `policy.compute_td_error()` method for TD-error calculation from a batch of ob...
class ComputeTDErrorMixin: '''Mixin class calculating TD-error (part of critic loss) per batch item. - Adds `policy.compute_td_error()` method for TD-error calculation from a batch of observations/actions/rewards/etc.. ''' def __init__(self): pass def compute_td_error(obs_t, act...
3
1
22
2
16
5
1
0.5
0
0
0
0
1
1
1
1
31
4
18
7
13
9
7
5
4
1
0
0
2
11,233
ray-project/ray
rllib/algorithms/sac/torch/default_sac_torch_rl_module.py
rllib.algorithms.sac.torch.default_sac_torch_rl_module.DefaultSACTorchRLModule
from ray.rllib.core.columns import Columns from ray.rllib.core.rl_module.apis import QNetAPI, TargetNetworkAPI from ray.rllib.algorithms.sac.sac_learner import ACTION_DIST_INPUTS_NEXT, QF_PREDS, QF_TWIN_PREDS, QF_TARGET_NEXT, ACTION_LOG_PROBS_NEXT, ACTION_PROBS_NEXT, ACTION_PROBS, ACTION_LOG_PROBS import gymnasium as g...
@DeveloperAPI class DefaultSACTorchRLModule(TorchRLModule, DefaultSACRLModule): def __init__(self, *args, **kwargs): pass @override(RLModule) def _forward_inference(self, batch: Dict) -> Dict[str, Any]: pass @override(RLModule) def _forward_exploration(self, batch: Dict, **kwargs) -...
17
1
24
3
14
7
2
0.47
2
5
0
0
7
0
7
7
181
28
105
41
89
49
64
33
56
6
1
1
15
11,234
ray-project/ray
rllib/algorithms/sac/torch/sac_torch_learner.py
rllib.algorithms.sac.torch.sac_torch_learner.SACTorchLearner
from ray.rllib.utils.metrics import ALL_MODULES, TD_ERROR_KEY import gymnasium as gym from ray.rllib.utils.typing import ModuleID, ParamDict, TensorType from ray.rllib.utils.annotations import override from ray.rllib.algorithms.sac.sac_learner import LOGPS_KEY, QF_LOSS_KEY, QF_MEAN_KEY, QF_MAX_KEY, QF_MIN_KEY, QF_PREDS...
class SACTorchLearner(DQNTorchLearner, SACLearner): '''Implements `torch`-specific SAC loss logic on top of `SACLearner` This ' Learner' class implements the loss in its `self.compute_loss_for_module()` method. In addition, it updates the target networks of the RLModule(s). ''' def build(self)...
10
1
71
6
48
18
4
0.4
2
3
0
0
3
0
3
3
227
22
148
42
130
59
49
28
45
6
1
2
11
11,235
ray-project/ray
rllib/algorithms/utils.py
rllib.algorithms.utils.AggregatorActor
from typing import List from ray.rllib.policy.sample_batch import MultiAgentBatch, SampleBatch from ray.util.annotations import DeveloperAPI from ray.rllib.utils.typing import EpisodeType from ray.rllib.algorithms.algorithm_config import AlgorithmConfig import tree import ray from ray.rllib.utils.actor_manager import F...
@DeveloperAPI(stability='alpha') class AggregatorActor(FaultAwareApply): '''Runs episode lists through ConnectorV2 pipeline and creates train batches. The actor should be co-located with a Learner worker. Ideally, there should be one or two aggregator actors per Learner worker (having even more per Learner ...
5
1
21
2
12
7
2
1.21
1
0
0
0
3
6
3
3
93
9
38
15
34
46
25
15
21
4
1
3
6
11,236
ray-project/ray
rllib/callbacks/callbacks.py
rllib.callbacks.callbacks.MemoryTrackingCallbacks
import gymnasium as gym from ray.rllib.utils.metrics.metrics_logger import MetricsLogger from ray.rllib.evaluation.episode_v2 import EpisodeV2 from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union import gc import tracemalloc import psutil from ray.rllib.env.base_env import BaseEnv import platform import...
class MemoryTrackingCallbacks(RLlibCallback): '''MemoryTrackingCallbacks can be used to trace and track memory usage in rollout workers. The Memory Tracking Callbacks uses tracemalloc and psutil to track python allocations during rollouts, in training or evaluation. The tracking data is logged ...
4
1
22
3
17
2
2
0.53
1
4
0
0
2
0
2
43
66
11
36
27
19
19
22
13
19
3
5
1
4
11,237
ray-project/ray
rllib/callbacks/callbacks.py
rllib.callbacks.callbacks.RLlibCallback
from ray.rllib.evaluation.episode_v2 import EpisodeV2 from ray.rllib.policy import Policy import gymnasium as gym from ray.rllib.core.rl_module.rl_module import RLModule from ray.tune.callback import _CallbackMeta from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.annotations import OldAPIStack,...
@PublicAPI class RLlibCallback(metaclass=_CallbackMeta): '''Abstract base class for RLlib callbacks (similar to Keras callbacks). These callbacks can be used for custom metrics and custom postprocessing. By default, all of these callbacks are no-ops. To configure custom training callbacks, subclass RLli...
41
20
29
2
10
16
1
1.5
1
3
0
1
17
0
17
41
529
61
187
170
17
281
35
18
17
1
4
0
17
11,238
ray-project/ray
rllib/connectors/action/clip.py
rllib.connectors.action.clip.ClipActionsConnector
from ray.rllib.connectors.connector import ActionConnector, ConnectorContext from ray.rllib.utils.typing import ActionConnectorDataType from ray.rllib.utils.annotations import OldAPIStack from typing import Any from ray.rllib.utils.spaces.space_utils import clip_action, get_base_struct_from_space @OldAPIStack class Cl...
@OldAPIStack class ClipActionsConnector(ActionConnector): def __init__(self, ctx: ConnectorContext): pass def transform(self, ac_data: ActionConnectorDataType) -> ActionConnectorDataType: pass def to_state(self): pass @staticmethod def from_state(ctx: ConnectorContext, par...
7
0
5
1
5
0
1
0
1
3
0
0
3
1
4
4
25
5
20
8
14
0
12
7
7
1
1
0
4
11,239
ray-project/ray
rllib/connectors/action/immutable.py
rllib.connectors.action.immutable.ImmutableActionsConnector
from ray.rllib.utils.numpy import make_action_immutable from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.utils.typing import ActionConnectorDataType import tree from ray.rllib.connectors.connector import ActionConnector, ConnectorContext from typing import Any @OldAPIStack class ImmutableActionsConne...
@OldAPIStack class ImmutableActionsConnector(ActionConnector): def transform(self, ac_data: ActionConnectorDataType) -> ActionConnectorDataType: pass def to_state(self): pass @staticmethod def from_state(ctx: ConnectorContext, params: Any): pass
6
0
6
1
5
0
1
0
1
2
0
0
2
0
3
3
22
4
18
6
13
0
10
5
6
1
1
0
3
11,240
ray-project/ray
rllib/connectors/action/normalize.py
rllib.connectors.action.normalize.NormalizeActionsConnector
from ray.rllib.utils.spaces.space_utils import get_base_struct_from_space, unsquash_action from ray.rllib.connectors.connector import ActionConnector, ConnectorContext from ray.rllib.utils.typing import ActionConnectorDataType from ray.rllib.utils.annotations import OldAPIStack from typing import Any @OldAPIStack clas...
@OldAPIStack class NormalizeActionsConnector(ActionConnector): def __init__(self, ctx: ConnectorContext): pass def transform(self, ac_data: ActionConnectorDataType) -> ActionConnectorDataType: pass def to_state(self): pass @staticmethod def from_state(ctx: ConnectorContext...
7
0
5
1
5
0
1
0
1
3
0
0
3
1
4
4
25
5
20
8
14
0
12
7
7
1
1
0
4
11,241
ray-project/ray
rllib/connectors/action/pipeline.py
rllib.connectors.action.pipeline.ActionConnectorPipeline
from ray.rllib.connectors.connector import ActionConnector, Connector, ConnectorContext, ConnectorPipeline from ray.rllib.utils.annotations import OldAPIStack from typing import Any, List from ray.rllib.connectors.registry import get_connector, register_connector from ray.rllib.utils.typing import ActionConnectorDataTy...
@OldAPIStack class ActionConnectorPipeline(ConnectorPipeline, ActionConnector): def __init__(self, ctx: ConnectorContext, connectors: List[Connector]): pass def __call__(self, ac_data: ActionConnectorDataType) -> ActionConnectorDataType: pass def to_state(self): pass @staticme...
7
0
8
0
8
0
2
0
2
8
1
0
3
1
4
4
38
3
35
16
29
0
28
14
23
3
1
2
8
11,242
ray-project/ray
rllib/connectors/agent/clip_reward.py
rllib.connectors.agent.clip_reward.ClipRewardAgentConnector
from ray.rllib.utils.annotations import OldAPIStack import numpy as np from typing import Any from ray.rllib.connectors.connector import AgentConnector, ConnectorContext from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.typing import AgentConnectorDataType @OldAPIStack class ClipRewardAgentCon...
@OldAPIStack class ClipRewardAgentConnector(AgentConnector): def __init__(self, ctx: ConnectorContext, sign=False, limit=None): pass def transform(self, ac_data: AgentConnectorDataType) -> AgentConnectorDataType: pass def to_state(self): pass @staticmethod def from_state(c...
7
0
8
1
8
0
2
0.03
1
4
0
0
3
2
4
4
38
5
32
9
26
1
19
8
14
4
1
1
7
11,243
ray-project/ray
rllib/connectors/agent/env_sampling.py
rllib.connectors.agent.env_sampling.EnvSamplingAgentConnector
from ray.rllib.connectors.connector import AgentConnector, ConnectorContext from typing import Any from ray.rllib.utils.typing import AgentConnectorDataType from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class EnvSamplingAgentConnector(AgentConnector): def __init__(self, ctx: ConnectorContext, s...
@OldAPIStack class EnvSamplingAgentConnector(AgentConnector): def __init__(self, ctx: ConnectorContext, sign=False, limit=None): pass def transform(self, ac_data: AgentConnectorDataType) -> AgentConnectorDataType: pass def to_state(self): pass @staticmethod def from_state(...
7
0
3
0
2
0
1
0.09
1
2
0
0
3
1
4
4
15
3
11
7
5
1
10
6
5
1
1
0
4
11,244
ray-project/ray
rllib/connectors/agent/mean_std_filter.py
rllib.connectors.agent.mean_std_filter.ConcurrentMeanStdObservationFilterAgentConnector
from ray.rllib.connectors.agent.synced_filter import SyncedFilterAgentConnector from ray.rllib.connectors.connector import ConnectorContext from gymnasium.spaces import Discrete, MultiDiscrete from ray.rllib.utils.filter import MeanStdFilter, ConcurrentMeanStdFilter from ray.rllib.utils.annotations import OldAPIStack f...
@OldAPIStack class ConcurrentMeanStdObservationFilterAgentConnector(MeanStdObservationFilterAgentConnector): '''A concurrent version of the MeanStdObservationFilterAgentConnector. This version's filter has all operations wrapped by a threading.RLock. It can therefore be safely used by multiple threads. ...
3
1
16
1
13
3
1
0.44
1
0
0
0
1
1
1
9
25
3
16
6
12
7
5
4
3
1
2
0
1
11,245
ray-project/ray
rllib/connectors/agent/mean_std_filter.py
rllib.connectors.agent.mean_std_filter.MeanStdObservationFilterAgentConnector
from typing import Any, List from ray.rllib.connectors.agent.synced_filter import SyncedFilterAgentConnector from ray.rllib.utils.filter import MeanStdFilter, ConcurrentMeanStdFilter from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.spaces.space_utils import get_base_struct_from_space from ray....
@OldAPIStack class MeanStdObservationFilterAgentConnector(SyncedFilterAgentConnector): '''A connector used to mean-std-filter observations. Incoming observations are filtered such that the output of this filter is on average zero and has a standard deviation of 1. This filtering is applied separately pe...
11
5
14
1
11
3
2
0.3
1
6
0
1
7
1
8
8
127
16
86
30
64
26
44
17
35
3
1
1
14
11,246
ray-project/ray
rllib/connectors/agent/obs_preproc.py
rllib.connectors.agent.obs_preproc.ObsPreprocessorConnector
from ray.rllib.models.preprocessors import get_preprocessor, NoPreprocessor from ray.rllib.policy.sample_batch import SampleBatch from typing import Any from ray.rllib.utils.typing import AgentConnectorDataType from ray.rllib.connectors.connector import AgentConnector, ConnectorContext from ray.rllib.utils.annotations ...
@OldAPIStack class ObsPreprocessorConnector(AgentConnector): '''A connector that wraps around existing RLlib observation preprocessors. This includes: - OneHotPreprocessor for Discrete and Multi-Discrete spaces. - GenericPixelPreprocessor and AtariRamPreprocessor for Atari spaces. - TupleFlatteningP...
8
2
7
1
6
1
2
0.4
1
4
0
0
4
1
5
5
52
10
30
10
23
12
21
9
15
3
1
1
8
11,247
ray-project/ray
rllib/connectors/agent/pipeline.py
rllib.connectors.agent.pipeline.AgentConnectorPipeline
from ray.rllib.utils.typing import ActionConnectorDataType, AgentConnectorDataType from ray.rllib.connectors.connector import AgentConnector, Connector, ConnectorContext, ConnectorPipeline from typing import Any, List from ray.rllib.connectors.registry import get_connector, register_connector from ray.rllib.utils.annot...
@OldAPIStack class AgentConnectorPipeline(ConnectorPipeline, AgentConnector): def __init__(self, ctx: ConnectorContext, connectors: List[Connector]): pass def reset(self, env_id: str): pass def on_policy_output(self, output: ActionConnectorDataType): pass def __call__(self, a...
9
0
7
0
7
0
2
0
2
8
1
0
5
1
6
6
49
5
44
23
34
0
35
19
28
3
1
2
12
11,248
ray-project/ray
rllib/connectors/agent/state_buffer.py
rllib.connectors.agent.state_buffer.StateBufferConnector
from ray.rllib.utils.typing import ActionConnectorDataType, AgentConnectorDataType from ray.rllib.core.columns import Columns from collections import defaultdict from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.utils.spaces.space_utils import get_base_struct_from_space import pickle from typing import...
@OldAPIStack class StateBufferConnector(AgentConnector): def __init__(self, ctx: ConnectorContext, states: Any=None): pass @override(Connector) def in_eval(self): pass def reset(self, env_id: str): pass def on_policy_output(self, ac_data: ActionConnectorDataType): ...
11
0
12
1
8
2
2
0.28
1
7
0
0
6
4
7
7
90
14
60
20
50
17
44
18
36
7
1
2
16
11,249
ray-project/ray
rllib/connectors/agent/synced_filter.py
rllib.connectors.agent.synced_filter.SyncedFilterAgentConnector
from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.connectors.connector import AgentConnector, ConnectorContext @OldAPIStack class SyncedFilterAgentConnector(AgentConnector): """An agent connector that filters with synchronized parameters.""" def __init__(self, ctx: ConnectorContext, *args, **...
@OldAPIStack class SyncedFilterAgentConnector(AgentConnector): '''An agent connector that filters with synchronized parameters.''' def __init__(self, ctx: ConnectorContext, *args, **kwargs): pass def apply_changes(self, other: 'Filter', *args, **kwargs) -> None: '''Updates self with state ...
8
5
6
0
3
3
1
0.94
1
3
0
0
6
0
6
6
43
8
18
7
11
17
15
7
8
2
1
1
7
11,250
ray-project/ray
rllib/connectors/agent/view_requirement.py
rllib.connectors.agent.view_requirement.ViewRequirementAgentConnector
from collections import defaultdict from typing import Any from ray.rllib.connectors.connector import AgentConnector, ConnectorContext from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.evaluation.collectors.agent_collector import AgentCollector from ray.rllib.policy.sample_batch import SampleBatch from...
@OldAPIStack class ViewRequirementAgentConnector(AgentConnector): '''This connector does 2 things: 1. It filters data columns based on view_requirements for training and inference. 2. It buffers the right amount of history for computing the sample batch for action computation. The output of this ...
8
1
18
2
13
3
2
0.42
1
7
0
0
4
2
5
5
112
14
69
19
62
29
37
18
31
6
1
2
11
11,251
ray-project/ray
rllib/connectors/common/add_observations_from_episodes_to_batch.py
rllib.connectors.common.add_observations_from_episodes_to_batch.AddObservationsFromEpisodesToBatch
from ray.rllib.utils.annotations import override from typing import Any, Dict, List, Optional from ray.rllib.core.columns import Columns from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.utils.typing import EpisodeType from ray.rllib.core.rl_module.rl_module import RLModule from ray.util.annotati...
@PublicAPI(stability='alpha') class AddObservationsFromEpisodesToBatch(ConnectorV2): '''Gets the last observation from a running episode and adds it to the batch. Note: This is one of the default env-to-module or Learner ConnectorV2 pieces that are added automatically by RLlib into every env-to-module/Learn...
5
2
38
2
26
11
3
1.85
1
7
0
0
2
1
2
2
167
16
53
22
33
98
15
5
12
5
1
3
6
11,252
ray-project/ray
rllib/connectors/common/add_states_from_episodes_to_batch.py
rllib.connectors.common.add_states_from_episodes_to_batch.AddStatesFromEpisodesToBatch
from ray.rllib.core import DEFAULT_MODULE_ID import tree from typing import Any, Dict, List, Optional import numpy as np from ray.rllib.utils.numpy import convert_to_numpy from ray.util.annotations import PublicAPI import gymnasium as gym from ray.rllib.core.columns import Columns from ray.rllib.utils.typing import Epi...
@PublicAPI(stability='alpha') class AddStatesFromEpisodesToBatch(ConnectorV2): '''Gets last STATE_OUT from running episode and adds it as STATE_IN to the batch. Note: This is one of the default env-to-module or Learner ConnectorV2 pieces that are added automatically by RLlib into every env-to-module/Learner...
5
2
85
5
61
20
9
1.43
1
7
0
0
2
1
2
2
329
30
123
29
103
176
37
11
34
16
1
4
17
11,253
ray-project/ray
rllib/connectors/common/add_time_dim_to_batch_and_zero_pad.py
rllib.connectors.common.add_time_dim_to_batch_and_zero_pad.AddTimeDimToBatchAndZeroPad
from ray.rllib.core.columns import Columns import tree from ray.util.annotations import PublicAPI from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.utils.typing import EpisodeType from ray.rllib.utils.postprocessing.zero_padding import create_mask_and_seq_lens, split_and_zero_pad from typing import...
@PublicAPI(stability='alpha') class AddTimeDimToBatchAndZeroPad(ConnectorV2): '''Adds an extra time dim (axis=1) to all data currently in the batch. Note: This is one of the default env-to-module or Learner ConnectorV2 pieces that are added automatically by RLlib into every env-to-module/Learner connector ...
6
2
50
3
37
11
7
1.2
1
7
0
0
3
1
3
3
280
31
113
32
92
136
43
15
39
15
1
5
20
11,254
ray-project/ray
rllib/connectors/common/agent_to_module_mapping.py
rllib.connectors.common.agent_to_module_mapping.AgentToModuleMapping
from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.util.annotations import PublicAPI from ray.rllib.core.rl_module.rl_module import RLModule, RLModuleSpec from ray.rllib.utils.annotations import override from collections import defaultdict from ray.rllib.utils.typing import EpisodeType, ModuleID from ra...
@PublicAPI(stability='alpha') class AgentToModuleMapping(ConnectorV2): '''ConnectorV2 that performs mapping of data from AgentID based to ModuleID based. Note: This is one of the default env-to-module or Learner ConnectorV2 pieces that are added automatically by RLlib into every env-to-module/Learner connec...
10
1
30
2
24
5
5
1.03
1
8
0
0
5
2
5
5
277
29
122
48
89
126
60
21
54
11
1
5
25
11,255
ray-project/ray
rllib/connectors/common/batch_individual_items.py
rllib.connectors.common.batch_individual_items.BatchIndividualItems
from ray.rllib.utils.typing import EpisodeType from ray.rllib.core import DEFAULT_MODULE_ID from ray.util.annotations import PublicAPI from ray.rllib.core.rl_module.multi_rl_module import MultiRLModule import gymnasium as gym from ray.rllib.core.columns import Columns from ray.rllib.connectors.connector_v2 import Conne...
@PublicAPI(stability='alpha') class BatchIndividualItems(ConnectorV2): '''Batches individual data-items (in lists) into tensors (with batch dimension). Note: This is one of the default env-to-module or Learner ConnectorV2 pieces that are added automatically by RLlib into every env-to-module/Learner connecto...
5
2
49
3
32
14
8
1.53
1
6
0
0
2
1
2
2
184
17
66
29
46
101
30
12
27
15
1
5
16
11,256
ray-project/ray
rllib/connectors/common/module_to_agent_unmapping.py
rllib.connectors.common.module_to_agent_unmapping.ModuleToAgentUnmapping
from ray.rllib.env.multi_agent_episode import MultiAgentEpisode from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.utils.typing import EpisodeType from ray.util.annotations import PublicAPI from ray.rllib.utils.annotations import override from collections import defaultdict from typing import Any,...
@PublicAPI(stability='alpha') class ModuleToAgentUnmapping(ConnectorV2): '''Performs flipping of `data` from ModuleID- to AgentID based mapping. Before mapping: data[module1] -> [col, e.g. ACTIONS] -> [dict mapping episode-identifying tuples to lists of data] data[module2] -> ... After mapping: ...
4
1
19
2
16
1
3
0.67
1
4
0
0
1
0
1
1
36
6
18
15
6
12
8
5
6
3
1
2
3
11,257
ray-project/ray
rllib/connectors/common/numpy_to_tensor.py
rllib.connectors.common.numpy_to_tensor.NumpyToTensor
from ray.rllib.core.rl_module.multi_rl_module import MultiRLModule from ray.util.annotations import PublicAPI from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.core.columns import Columns import gymnasium as gym from ray.rllib.core import DEFAULT_MODULE_ID from ray.rllib.connectors.connector_v2 imp...
@PublicAPI(stability='alpha') class NumpyToTensor(ConnectorV2): '''Converts numpy arrays across the entire input data into (framework) tensors. The framework information is received via the provided `rl_module` arg in the `__call__()` method. Note: This is one of the default env-to-module or Learner Con...
5
2
34
2
26
7
4
0.89
1
6
0
0
2
3
2
2
109
9
53
29
31
47
23
10
20
6
1
2
8
11,258
ray-project/ray
rllib/connectors/common/tensor_to_numpy.py
rllib.connectors.common.tensor_to_numpy.TensorToNumpy
from ray.util.annotations import PublicAPI from ray.rllib.utils.annotations import override from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.utils.typing import EpisodeType from typing import Any, Dict, List, Optional from ray.rllib.utils.n...
@PublicAPI(stability='alpha') class TensorToNumpy(ConnectorV2): '''Converts (framework) tensors across the entire input data into numpy arrays.''' @override(ConnectorV2) def __call__(self, *, rl_module: RLModule, batch: Dict[str, Any], episodes: List[EpisodeType], explore: Optional[bool]=None, shared_data: ...
4
1
11
0
11
0
1
0.08
1
4
0
0
1
0
1
1
15
1
13
12
1
1
3
2
1
1
1
0
1
11,259
ray-project/ray
rllib/connectors/connector.py
rllib.connectors.connector.ActionConnector
from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.utils.typing import ActionConnectorDataType, AgentConnectorDataType, AlgorithmConfigDict, TensorType @OldAPIStack class ActionConnector(Connector): """Action connector connects policy outputs including actions, to user environments. An act...
@OldAPIStack class ActionConnector(Connector): '''Action connector connects policy outputs including actions, to user environments. An action connector transforms a single piece of policy output in ActionConnectorDataType format, which is basically PolicyOutputType plus env and agent IDs. Any fu...
4
3
11
3
2
7
1
6.8
1
1
0
0
2
0
2
28
52
13
5
3
2
34
5
3
2
1
5
0
2
11,260
ray-project/ray
rllib/connectors/connector.py
rllib.connectors.connector.AgentConnector
from ray.rllib.utils.typing import ActionConnectorDataType, AgentConnectorDataType, AlgorithmConfigDict, TensorType from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class AgentConnector(Connector): """Connector connecting user environm...
@OldAPIStack class AgentConnector(Connector): '''Connector connecting user environments to RLlib policies. An agent connector transforms a list of agent data in AgentConnectorDataType format into a new list in the same AgentConnectorDataTypes format. The input API is designed so agent connectors can hav...
6
5
14
2
3
8
1
6.57
1
4
0
0
4
0
4
30
137
31
14
7
7
92
10
5
5
1
5
0
4
11,261
ray-project/ray
rllib/connectors/connector.py
rllib.connectors.connector.Connector
from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union from ray.rllib.utils.annotations import OldAPIStack import abc @OldAPIStack class Connector(abc.ABC): """Connector base class. A connector is a step of transformation, of either envrionment data before they get to a policy, or policy output b...
@OldAPIStack class Connector(abc.ABC): '''Connector base class. A connector is a step of transformation, of either envrionment data before they get to a policy, or policy output before it is sent back to the environment. Connectors may be training-aware, for example, behave slightly differently duri...
9
3
6
1
2
3
1
1.93
1
5
1
2
5
1
6
26
55
14
14
9
6
27
13
8
6
1
4
0
6
11,262
ray-project/ray
rllib/connectors/connector.py
rllib.connectors.connector.ConnectorContext
from ray.rllib.utils.typing import ActionConnectorDataType, AgentConnectorDataType, AlgorithmConfigDict, TensorType from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union from ray.rllib.policy.view_requirement import ViewRequirement from ray.rllib.utils.annotations import OldAPIStack import gymnasium as gym @...
@OldAPIStack class ConnectorContext: '''Data bits that may be needed for running connectors. Note(jungong) : we need to be really careful with the data fields here. E.g., everything needs to be serializable, in case we need to fetch them in a remote setting. ''' def __init__(self, config: Algor...
5
3
21
2
12
7
1
0.81
0
2
0
0
1
6
2
2
54
7
26
18
14
21
10
9
7
1
0
0
2
11,263
ray-project/ray
rllib/connectors/connector.py
rllib.connectors.connector.ConnectorPipeline
import abc from ray.rllib.utils.annotations import OldAPIStack from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union @OldAPIStack class ConnectorPipeline(abc.ABC): """Utility class for quick manipulation of a connector pipeline.""" def __init__(self, ctx: ConnectorContext, connectors: List[Connector...
@OldAPIStack class ConnectorPipeline(abc.ABC): '''Utility class for quick manipulation of a connector pipeline.''' def __init__(self, ctx: ConnectorContext, connectors: List[Connector]): pass def in_training(self): pass def in_eval(self): pass def remove(self, name: str):...
12
7
13
1
8
3
3
0.42
1
8
2
0
10
1
10
30
143
24
84
22
73
35
61
22
50
9
4
4
29
11,264
ray-project/ray
rllib/connectors/connector_pipeline_v2.py
rllib.connectors.connector_pipeline_v2.ConnectorPipelineV2
from ray.rllib.utils.metrics.utils import to_snake_case from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.utils.metrics import TIMERS, CONNECTOR_PIPELINE_TIMER, CONNECTOR_TIMERS from ray.rllib.utils.typing import EpisodeType, StateDict import gymnasium as gym from ray.rllib.utils.metrics.metrics_...
@PublicAPI(stability='alpha') class ConnectorPipelineV2(ConnectorV2): '''Utility class for quick manipulation of a connector pipeline.''' @override(ConnectorV2) def recompute_output_observation_space(self, input_observation_space: gym.Space, input_action_space: gym.Space) -> gym.Space: pass @ove...
34
9
16
1
12
3
3
0.3
1
12
0
0
21
1
21
21
376
46
254
102
179
77
134
49
112
9
1
3
57
11,265
ray-project/ray
rllib/connectors/connector_v2.py
rllib.connectors.connector_v2.ConnectorV2
from ray.rllib.utils.metrics.metrics_logger import MetricsLogger from ray.util.annotations import PublicAPI from collections import defaultdict from ray.rllib.utils import force_list from typing import Any, Callable, Collection, Dict, Iterator, List, Optional, Tuple, Union from ray.rllib.utils.checkpoints import Checkp...
@PublicAPI(stability='alpha') class ConnectorV2(Checkpointable, abc.ABC): '''Base class defining the API for an individual "connector piece". A ConnectorV2 ("connector piece") is usually part of a whole series of connector pieces within a so-called connector pipeline, which in itself also abides to this ...
41
14
41
3
12
26
3
2.27
2
9
0
0
16
5
21
41
987
95
275
121
183
623
128
52
105
13
4
4
61
11,266
ray-project/ray
rllib/connectors/env_to_module/env_to_module_pipeline.py
rllib.connectors.env_to_module.env_to_module_pipeline.EnvToModulePipeline
from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.utils.typing import EpisodeType from ray.rllib.utils.metrics import ENV_TO_MODULE_SUM_EPISODES_LENGTH_IN, ENV_TO_MODULE_SUM_EPISODES_LENGTH_OUT from ray.util.annotations import PublicAPI from ray.rllib.utils.annotations import override from ray.rlli...
@PublicAPI(stability='alpha') class EnvToModulePipeline(ConnectorPipelineV2): @override(ConnectorPipelineV2) def __call__(self, *, rl_module: RLModule, batch: Optional[Dict[str, Any]]=None, episodes: List[EpisodeType], explore: bool, shared_data: Optional[dict]=None, metrics: Optional[MetricsLogger]=None, **kw...
4
0
38
3
31
4
5
0.12
1
6
0
0
1
0
1
1
40
3
33
14
20
4
8
3
6
5
1
1
5
11,267
ray-project/ray
rllib/connectors/env_to_module/flatten_observations.py
rllib.connectors.env_to_module.flatten_observations.FlattenObservations
import tree from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.utils.typing import AgentID, EpisodeType from typing import Any, Collection, Dict, List, Optional from ray.rllib.connectors.connector_v2 import ConnectorV2 from gymnasium.spaces import Box import numpy as np import gymnasium as gym from ...
@PublicAPI(stability='alpha') class FlattenObservations(ConnectorV2): '''A connector piece that flattens all observation components into a 1D array. - Should be used only in env-to-module pipelines. - Works directly on the incoming episodes list and changes the last observation in-place (write the flatt...
7
2
36
2
28
6
3
0.99
1
6
0
0
3
3
3
3
191
18
87
36
60
86
29
13
25
4
1
3
9
11,268
ray-project/ray
rllib/connectors/env_to_module/mean_std_filter.py
rllib.connectors.env_to_module.mean_std_filter.MeanStdFilter
import numpy as np from ray.rllib.utils.annotations import override from ray.rllib.utils.filter import MeanStdFilter as _MeanStdFilter, RunningStat from ray.util.annotations import PublicAPI from ray.rllib.connectors.connector_v2 import ConnectorV2 from typing import Any, Collection, Dict, List, Optional, Union from ra...
@PublicAPI(stability='alpha') class MeanStdFilter(ConnectorV2): '''A connector used to mean-std-filter observations. Incoming observations are filtered such that the output of this filter is on average 0.0 and has a standard deviation of 1.0. If the observation space is a (possibly nested) dict, this fi...
18
3
23
1
18
4
2
0.28
1
9
0
0
8
6
9
9
236
24
166
65
121
46
67
30
57
4
1
2
22
11,269
ray-project/ray
rllib/connectors/env_to_module/prev_actions_prev_rewards.py
rllib.connectors.env_to_module.prev_actions_prev_rewards.PrevActionsPrevRewards
from ray.rllib.utils.typing import EpisodeType from ray.util.annotations import PublicAPI import numpy as np from ray.rllib.connectors.connector_v2 import ConnectorV2 import gymnasium as gym from ray.rllib.utils.spaces.space_utils import batch as batch_fn, flatten_to_single_ndarray from ray.rllib.core.rl_module.rl_modu...
@PublicAPI(stability='alpha') class PrevActionsPrevRewards(ConnectorV2): '''A connector piece that adds previous rewards and actions to the input obs. - Requires Columns.OBS to be already a part of the batch. - This connector makes the assumption that under the Columns.OBS key in batch, there is either ...
8
2
27
2
21
4
2
0.53
1
8
0
0
4
3
4
4
150
14
89
40
60
47
30
16
25
4
1
2
9
11,270
ray-project/ray
rllib/connectors/env_to_module/write_observations_to_episodes.py
rllib.connectors.env_to_module.write_observations_to_episodes.WriteObservationsToEpisodes
from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.utils.typing import EpisodeType from ray.util.annotations import PublicAPI from ray.rllib.core.columns import Columns from typing import Any, Dict, List, Optional from ray.rllib.utils.annotat...
@PublicAPI(stability='alpha') class WriteObservationsToEpisodes(ConnectorV2): '''Writes the observations from the batch into the running episodes. Note: This is one of the default env-to-module ConnectorV2 pieces that are added automatically by RLlib into every env-to-module connector pipelines, unless ...
4
1
38
3
23
12
3
3.16
1
5
0
0
1
0
1
1
120
16
25
14
13
79
10
4
8
3
1
1
3
11,271
ray-project/ray
rllib/connectors/learner/add_columns_from_episodes_to_train_batch.py
rllib.connectors.learner.add_columns_from_episodes_to_train_batch.AddColumnsFromEpisodesToTrainBatch
from ray.util.annotations import PublicAPI from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.utils.typing import EpisodeType from ray.rllib.core.columns import Columns from ray.rllib.utils.annotations import override from ray.rllib.core.rl_module.rl_module import RLModule from typing import Any, ...
@PublicAPI(stability='alpha') class AddColumnsFromEpisodesToTrainBatch(ConnectorV2): '''Adds actions/rewards/terminateds/... to train batch. Excluding the infos column. Note: This is one of the default Learner ConnectorV2 pieces that are added automatically by RLlib into every Learner connector pipeline, un...
4
1
104
6
90
8
14
0.54
1
6
0
0
1
0
1
1
156
14
92
15
80
50
20
5
18
14
1
3
14
11,272
ray-project/ray
rllib/connectors/learner/add_infos_from_episodes_to_train_batch.py
rllib.connectors.learner.add_infos_from_episodes_to_train_batch.AddInfosFromEpisodesToTrainBatch
from ray.rllib.utils.typing import EpisodeType from ray.rllib.core.columns import Columns from ray.util.annotations import PublicAPI from typing import Any, Dict, List, Optional from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.utils.annotat...
@PublicAPI(stability='alpha') class AddInfosFromEpisodesToTrainBatch(ConnectorV2): '''Adds the infos column to th train batch. If provided with `episodes` data, this connector piece makes sure that the final train batch going into the RLModule for updating (`forward_train()` call) contains an `infos` co...
4
1
25
1
23
1
3
0.44
1
5
0
0
1
0
1
1
40
4
25
13
13
11
6
3
4
3
1
2
3
11,273
ray-project/ray
rllib/connectors/learner/add_next_observations_from_episodes_to_train_batch.py
rllib.connectors.learner.add_next_observations_from_episodes_to_train_batch.AddNextObservationsFromEpisodesToTrainBatch
from typing import Any, Dict, List, Optional from ray.rllib.utils.annotations import override from ray.util.annotations import PublicAPI from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.utils.typing import EpisodeType from ray.rllib.core.co...
@PublicAPI(stability='alpha') class AddNextObservationsFromEpisodesToTrainBatch(ConnectorV2): '''Adds the NEXT_OBS column with the correct episode observations to train batch. - Operates on a list of Episode objects. - Gets all observation(s) from all the given episodes (except the very first ones) and ...
4
1
27
1
24
2
3
2.15
1
5
0
0
1
0
1
1
92
10
26
13
14
56
7
3
5
3
1
1
3
11,274
ray-project/ray
rllib/connectors/learner/add_one_ts_to_episodes_and_truncate.py
rllib.connectors.learner.add_one_ts_to_episodes_and_truncate.AddOneTsToEpisodesAndTruncate
from ray.rllib.core.columns import Columns from ray.rllib.env.multi_agent_episode import MultiAgentEpisode from ray.util.annotations import PublicAPI from ray.rllib.utils.annotations import override from ray.rllib.utils.postprocessing.episodes import add_one_ts_to_episodes_and_truncate from ray.rllib.core.rl_module.rl_...
@PublicAPI(stability='alpha') class AddOneTsToEpisodesAndTruncate(ConnectorV2): '''Adds an artificial timestep to all incoming episodes at the end. In detail: The last observations, infos, actions, and all `extra_model_outputs` will be duplicated and appended to each episode's data. An extra 0.0 reward ...
4
1
87
10
43
35
5
2.04
1
6
0
0
1
0
1
1
155
19
45
17
33
92
17
7
15
5
1
3
5
11,275
ray-project/ray
rllib/connectors/learner/compute_returns_to_go.py
rllib.connectors.learner.compute_returns_to_go.ComputeReturnsToGo
from ray.rllib.core.rl_module.multi_rl_module import MultiRLModule import scipy from ray.rllib.utils.typing import EpisodeType from typing import Any, List, Dict from ray.rllib.core.columns import Columns from ray.rllib.connectors.connector_v2 import ConnectorV2 class ComputeReturnsToGo(ConnectorV2): """Learner Co...
class ComputeReturnsToGo(ConnectorV2): '''Learner ConnectorV2 piece computing discounted returns to go till end of episode. This ConnectorV2: - Operates on a list of Episode objects (single- or multi-agent). - Should be used only in the Learner pipeline as a preparation for an upcoming loss computa...
3
2
22
2
17
4
2
0.53
1
3
0
0
2
1
2
2
58
6
34
21
18
18
11
8
8
2
1
1
3
11,276
ray-project/ray
rllib/connectors/learner/general_advantage_estimation.py
rllib.connectors.learner.general_advantage_estimation.GeneralAdvantageEstimation
from ray.rllib.utils.postprocessing.value_predictions import compute_value_targets from ray.rllib.core.rl_module.apis.value_function_api import ValueFunctionAPI from ray.rllib.core.columns import Columns from ray.rllib.utils.annotations import override from ray.rllib.evaluation.postprocessing import Postprocessing from...
class GeneralAdvantageEstimation(ConnectorV2): '''Learner ConnectorV2 piece computing GAE advantages and value targets on episodes. This ConnectorV2: - Operates on a list of Episode objects (single- or multi-agent). - Should be used only in the Learner pipeline and as one of the last pieces (due to...
4
2
76
5
52
19
4
0.53
1
4
0
0
2
3
2
2
176
14
106
30
88
56
33
15
30
6
1
2
7
11,277
ray-project/ray
rllib/connectors/learner/learner_connector_pipeline.py
rllib.connectors.learner.learner_connector_pipeline.LearnerConnectorPipeline
from ray.util.annotations import PublicAPI from ray.rllib.utils.annotations import override from ray.rllib.utils.metrics import ALL_MODULES, LEARNER_CONNECTOR, LEARNER_CONNECTOR_SUM_EPISODES_LENGTH_IN, LEARNER_CONNECTOR_SUM_EPISODES_LENGTH_OUT from ray.rllib.utils.metrics.metrics_logger import MetricsLogger from ray.rl...
@PublicAPI(stability='alpha') class LearnerConnectorPipeline(ConnectorPipelineV2): @override(ConnectorPipelineV2) def __call__(self, *, rl_module: RLModule, batch: Optional[Dict[str, Any]]=None, episodes: List[EpisodeType], explore: bool=False, shared_data: Optional[dict]=None, metrics: Optional[MetricsLogger]...
4
0
39
3
32
4
5
0.12
1
6
0
0
1
0
1
1
41
3
34
14
21
4
8
3
6
5
1
1
5
11,278
ray-project/ray
rllib/connectors/module_to_env/get_actions.py
rllib.connectors.module_to_env.get_actions.GetActions
from ray.rllib.core.columns import Columns from typing import Any, Dict, List, Optional from ray.rllib.utils.typing import EpisodeType from ray.util.annotations import PublicAPI from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.env.multi_age...
@PublicAPI(stability='alpha') class GetActions(ConnectorV2): '''Connector piece sampling actions from ACTION_DIST_INPUTS from an RLModule. Note: This is one of the default module-to-env ConnectorV2 pieces that are added automatically by RLlib into every module-to-env connector pipeline, unless `config.a...
5
1
23
3
17
3
5
0.86
1
4
0
0
2
0
2
2
79
12
36
18
23
31
22
8
19
6
1
2
9
11,279
ray-project/ray
rllib/connectors/module_to_env/listify_data_for_vector_env.py
rllib.connectors.module_to_env.listify_data_for_vector_env.ListifyDataForVectorEnv
from ray.rllib.utils.annotations import override from ray.util.annotations import PublicAPI from typing import Any, Dict, List, Optional from ray.rllib.utils.spaces.space_utils import batch as batch_fn from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.core.columns import Columns from ray.rllib.co...
@PublicAPI(stability='alpha') class ListifyDataForVectorEnv(ConnectorV2): '''Performs conversion from ConnectorV2-style format to env/episode insertion. Note: This is one of the default module-to-env ConnectorV2 pieces that are added automatically by RLlib into every module-to-env connector pipeline, un...
4
1
33
2
26
5
5
1.14
1
4
0
0
1
0
1
1
69
9
28
16
16
32
15
6
13
5
1
3
5
11,280
ray-project/ray
rllib/connectors/module_to_env/module_to_env_pipeline.py
rllib.connectors.module_to_env.module_to_env_pipeline.ModuleToEnvPipeline
from ray.util.annotations import PublicAPI from ray.rllib.connectors.connector_pipeline_v2 import ConnectorPipelineV2 @PublicAPI(stability='alpha') class ModuleToEnvPipeline(ConnectorPipelineV2): pass
@PublicAPI(stability='alpha') class ModuleToEnvPipeline(ConnectorPipelineV2): pass
2
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
2
0
2
1
1
0
2
1
1
0
1
0
0
11,281
ray-project/ray
rllib/connectors/module_to_env/normalize_and_clip_actions.py
rllib.connectors.module_to_env.normalize_and_clip_actions.NormalizeAndClipActions
from ray.rllib.utils.typing import EpisodeType import copy from ray.util.annotations import PublicAPI from typing import Any, Dict, List, Optional import gymnasium as gym from ray.rllib.utils.annotations import override from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.utils.spaces.space_utils im...
@PublicAPI(stability='alpha') class NormalizeAndClipActions(ConnectorV2): '''Normalizes or clips actions in the input data (coming from the RLModule). Note: This is one of the default module-to-env ConnectorV2 pieces that are added automatically by RLlib into every module-to-env connector pipeline, unle...
8
3
23
2
14
7
2
1.18
1
5
0
0
3
3
3
3
127
18
50
32
22
59
21
9
16
3
1
1
7
11,282
ray-project/ray
rllib/connectors/module_to_env/remove_single_ts_time_rank_from_batch.py
rllib.connectors.module_to_env.remove_single_ts_time_rank_from_batch.RemoveSingleTsTimeRankFromBatch
from typing import Any, Dict, List, Optional from ray.rllib.core.rl_module.rl_module import RLModule import numpy as np import tree from ray.rllib.utils.typing import EpisodeType from ray.rllib.connectors.connector_v2 import ConnectorV2 from ray.rllib.core.columns import Columns from ray.rllib.utils.annotations import ...
@PublicAPI(stability='alpha') class RemoveSingleTsTimeRankFromBatch(ConnectorV2): ''' Note: This is one of the default module-to-env ConnectorV2 pieces that are added automatically by RLlib into every module-to-env connector pipeline, unless `config.add_default_connectors_to_module_to_env_pipeline` is s...
5
1
19
2
15
3
3
0.78
1
4
0
0
1
0
1
1
56
8
27
14
14
21
13
4
10
4
1
2
6
11,283
ray-project/ray
rllib/connectors/module_to_env/unbatch_to_individual_items.py
rllib.connectors.module_to_env.unbatch_to_individual_items.UnBatchToIndividualItems
from ray.util.annotations import PublicAPI from ray.rllib.utils.spaces.space_utils import unbatch as unbatch_fn from ray.rllib.core.rl_module.rl_module import RLModule from ray.rllib.utils.annotations import override from typing import Any, Dict, List, Optional import tree from ray.rllib.utils.typing import EpisodeType...
@PublicAPI(stability='alpha') class UnBatchToIndividualItems(ConnectorV2): '''Unbatches the given `data` back into the individual-batch-items format. Note: This is one of the default module-to-env ConnectorV2 pieces that are added automatically by RLlib into every module-to-env connector pipeline, unles...
4
1
54
3
39
12
10
0.71
1
7
0
0
1
0
1
1
78
8
41
19
29
29
25
9
23
10
1
5
10
11,284
ray-project/ray
rllib/core/columns.py
rllib.core.columns.Columns
from ray.util.annotations import DeveloperAPI @DeveloperAPI class Columns: """Definitions of common column names for RL data, e.g. 'obs', 'rewards', etc.. Note that this replaces the `SampleBatch` and `Postprocessing` columns (of the same name). """ OBS = 'obs' INFOS = 'infos' ACTIONS = 'a...
@DeveloperAPI class Columns: '''Definitions of common column names for RL data, e.g. 'obs', 'rewards', etc.. Note that this replaces the `SampleBatch` and `Postprocessing` columns (of the same name). ''' pass
2
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
69
11
29
29
28
29
29
29
28
0
0
0
0
11,285
ray-project/ray
rllib/core/learner/learner.py
rllib.core.learner.learner.Learner
from ray.rllib.policy.sample_batch import MultiAgentBatch, SampleBatch import ray from ray.rllib.core.learner.training_data import TrainingData from ray.rllib.policy.policy import PolicySpec from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic, OverrideToImplementCustomLogic_CallToSuperRecom...
null
102
40
24
3
12
10
2
0.88
1
13
1
0
55
17
60
60
1,706
247
777
297
548
684
380
139
318
19
1
4
142
11,286
ray-project/ray
rllib/core/learner/learner_group.py
rllib.core.learner.learner_group.LearnerGroup
from ray.rllib.utils.actor_manager import FaultTolerantActorManager, RemoteCallResults, ResultOrError from functools import partial from ray.rllib.core.learner.training_data import TrainingData from ray.rllib.core.rl_module.rl_module import RLModuleSpec from ray._common.deprecation import Deprecated import itertools fr...
null
34
11
34
2
22
10
3
0.48
1
14
2
0
25
8
26
26
915
80
564
177
433
273
196
75
167
17
1
5
78
11,287
ray-project/ray
rllib/core/learner/torch/torch_learner.py
rllib.core.learner.torch.torch_learner.TorchLearner
from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic, OverrideToImplementCustomLogic_CallToSuperRecommended import contextlib from ray.rllib.core.rl_module.torch.torch_rl_module import TorchCompileConfig, TorchDDPRLModule, TorchRLModule from ray.rllib.core.rl_module.multi_rl_module import Mu...
class TorchLearner(Learner): def __init__(self, **kwargs): pass @OverrideToImplementCustomLogic @override(Learner) def configure_optimizers_for_module(self, module_id: ModuleID, config: 'AlgorithmConfig'=None) -> None: pass def _uncompiled_update(self, batch: Dict, **kwargs): ...
56
5
20
1
15
4
3
0.26
1
9
0
0
23
10
27
27
603
64
427
131
346
113
202
85
172
13
1
5
84
11,288
ray-project/ray
rllib/core/models/base.py
rllib.core.models.base.ActorCriticEncoder
from ray.rllib.utils.annotations import ExperimentalAPI, override from ray.rllib.core.models.configs import ModelConfig @ExperimentalAPI class ActorCriticEncoder(Encoder): """An encoder that potentially holds two stateless encoders. This is a special case of Encoder that can either enclose a single, share...
@ExperimentalAPI class ActorCriticEncoder(Encoder): '''An encoder that potentially holds two stateless encoders. This is a special case of Encoder that can either enclose a single, shared encoder or two separate encoders: One for the actor and one for the critic. The two encoders are of the same type, a...
5
1
22
1
20
1
4
0.16
1
2
0
0
2
3
2
36
56
6
43
11
39
7
18
10
15
5
6
2
8
11,289
ray-project/ray
rllib/core/models/base.py
rllib.core.models.base.Encoder
from ray.rllib.utils.annotations import ExperimentalAPI, override import abc @ExperimentalAPI class Encoder(Model, abc.ABC): """The framework-agnostic base class for all RLlib encoders. Encoders are used to transform observations to a latent space. Therefore, their `input_specs` contains the observation s...
@ExperimentalAPI class Encoder(Model, abc.ABC): '''The framework-agnostic base class for all RLlib encoders. Encoders are used to transform observations to a latent space. Therefore, their `input_specs` contains the observation space dimensions. Similarly, their `output_specs` contains the latent space ...
4
2
23
4
1
18
1
24.33
2
1
0
2
1
0
1
34
98
22
3
3
0
73
2
2
0
1
5
0
1
11,290
ray-project/ray
rllib/core/models/base.py
rllib.core.models.base.Model
from typing import List, Optional, Tuple, Union from ray.rllib.utils.annotations import ExperimentalAPI, override from ray.rllib.utils.typing import TensorType import abc from ray.rllib.core.models.specs.specs_base import Spec from ray.rllib.core.models.configs import ModelConfig @ExperimentalAPI class Model(abc.ABC):...
@ExperimentalAPI class Model(abc.ABC): '''Framework-agnostic base class for RLlib models. Models are low-level neural network components that offer input- and output-specification, a forward method, and a get_initial_state method. Models are composed in RLModules. Usage Example together with ModelCo...
24
10
8
1
3
3
1
1.7
1
3
0
1
13
3
13
33
166
42
46
26
23
78
31
19
15
2
4
1
16
11,291
ray-project/ray
rllib/core/models/base.py
rllib.core.models.base.StatefulActorCriticEncoder
from ray.rllib.core.models.configs import ModelConfig from ray.rllib.core.columns import Columns from ray.rllib.utils.annotations import ExperimentalAPI, override @ExperimentalAPI class StatefulActorCriticEncoder(Encoder): """An encoder that potentially holds two potentially stateful encoders. This is a speci...
@ExperimentalAPI class StatefulActorCriticEncoder(Encoder): '''An encoder that potentially holds two potentially stateful encoders. This is a special case of Encoder that can either enclose a single, shared encoder or two separate encoders: One for the actor and one for the critic. The two encoders are ...
7
1
17
2
14
1
2
0.28
1
2
0
0
3
3
3
37
71
12
46
17
40
13
28
15
24
2
6
1
6
11,292
ray-project/ray
rllib/core/models/catalog.py
rllib.core.models.catalog.Catalog
import functools import dataclasses from ray.rllib.models.utils import get_filter_config from ray._common.deprecation import deprecation_warning, DEPRECATED_VALUE from ray.rllib.utils.spaces.simplex import Simplex import enum from ray.rllib.core.models.base import Encoder import numpy as np from ray.rllib.core.models.c...
class Catalog: '''Describes the sub-module-architectures to be used in RLModules. RLlib's native RLModules get their Models from a Catalog object. By default, that Catalog builds the configs it has as attributes. This component was build to be hackable and extensible. You can inject custom componen...
22
10
48
5
27
15
3
0.7
0
6
1
0
6
6
10
10
548
73
279
76
226
196
87
38
73
13
0
3
32
11,293
ray-project/ray
rllib/core/models/configs.py
rllib.core.models.configs.ActorCriticEncoderConfig
from ray.rllib.utils.annotations import ExperimentalAPI from dataclasses import dataclass, field @ExperimentalAPI @dataclass class ActorCriticEncoderConfig(ModelConfig): """Configuration for an ActorCriticEncoder. The base encoder functions like other encoders in RLlib. It is wrapped by the ActorCriticEnc...
@ExperimentalAPI @dataclass class ActorCriticEncoderConfig(ModelConfig): '''Configuration for an ActorCriticEncoder. The base encoder functions like other encoders in RLlib. It is wrapped by the ActorCriticEncoder to provides a shared encoder Model to use in RLModules that provides twofold outputs: one ...
5
1
21
2
19
0
4
0.5
1
2
1
0
1
0
1
23
42
6
24
14
13
12
14
7
10
4
5
2
4
11,294
ray-project/ray
rllib/core/models/configs.py
rllib.core.models.configs.CNNEncoderConfig
from typing import Callable, Dict, List, Optional, Tuple, TYPE_CHECKING, Union import numpy as np from dataclasses import dataclass, field from ray.rllib.utils.annotations import ExperimentalAPI from ray.rllib.models.torch.misc import same_padding, same_padding_transpose_after_stride, valid_padding @ExperimentalAPI @d...
@ExperimentalAPI @dataclass class CNNEncoderConfig(ModelConfig): '''Configuration for a convolutional (encoder) network. The configured CNN encodes 3D-observations into a latent space. The stack of layers is composed of a sequence of convolutional layers. `input_dims` describes the shape of the input te...
8
1
21
3
16
3
4
1.53
1
4
0
0
3
0
3
25
177
21
62
23
54
95
40
21
34
6
5
2
13
11,295
ray-project/ray
rllib/core/models/configs.py
rllib.core.models.configs.CNNTransposeHeadConfig
from dataclasses import dataclass, field from ray.rllib.utils.annotations import ExperimentalAPI from ray.rllib.models.torch.misc import same_padding, same_padding_transpose_after_stride, valid_padding from typing import Callable, Dict, List, Optional, Tuple, TYPE_CHECKING, Union @ExperimentalAPI @dataclass class CNNT...
@ExperimentalAPI @dataclass class CNNTransposeHeadConfig(ModelConfig): '''Configuration for a convolutional transpose head (decoder) network. The configured Model transforms 1D-observations into an image space. The stack of layers is composed of an initial Dense layer, followed by a sequence of Conv2DTr...
8
1
16
1
12
3
3
3.04
1
4
0
0
3
0
3
25
252
26
56
28
48
170
35
26
29
4
5
1
9
11,296
ray-project/ray
rllib/core/models/configs.py
rllib.core.models.configs.FreeLogStdMLPHeadConfig
from ray.rllib.utils.annotations import ExperimentalAPI from dataclasses import dataclass, field @ExperimentalAPI @dataclass class FreeLogStdMLPHeadConfig(_MLPConfig): """Configuration for an MLPHead with a floating second half of outputs. This model can be useful together with Gaussian Distributions. Thi...
@ExperimentalAPI @dataclass class FreeLogStdMLPHeadConfig(_MLPConfig): '''Configuration for an MLPHead with a floating second half of outputs. This model can be useful together with Gaussian Distributions. This gaussian distribution would be conditioned as follows: - The first half of outputs from t...
6
1
10
2
8
0
2
2.94
1
2
0
0
2
0
2
26
84
13
18
6
12
53
11
5
6
2
6
1
4
11,297
ray-project/ray
rllib/core/models/configs.py
rllib.core.models.configs.MLPEncoderConfig
from dataclasses import dataclass, field from ray.rllib.utils.annotations import ExperimentalAPI @ExperimentalAPI @dataclass class MLPEncoderConfig(_MLPConfig): """Configuration for an MLP that acts as an encoder. See _MLPConfig for usage details. Example: .. testcode:: # Configuration: ...
@ExperimentalAPI @dataclass class MLPEncoderConfig(_MLPConfig): '''Configuration for an MLP that acts as an encoder. See _MLPConfig for usage details. Example: .. testcode:: # Configuration: config = MLPEncoderConfig( input_dims=[4], # must be 1D tensor hidden_la...
5
1
11
3
8
0
2
4
1
1
0
0
1
0
1
25
61
11
10
5
5
40
8
4
4
2
6
1
2
11,298
ray-project/ray
rllib/core/models/configs.py
rllib.core.models.configs.MLPHeadConfig
from dataclasses import dataclass, field from ray.rllib.utils.annotations import ExperimentalAPI @ExperimentalAPI @dataclass class MLPHeadConfig(_MLPConfig): """Configuration for an MLP head. See _MLPConfig for usage details. Example: .. testcode:: # Configuration: config = MLPHeadC...
@ExperimentalAPI @dataclass class MLPHeadConfig(_MLPConfig): '''Configuration for an MLP head. See _MLPConfig for usage details. Example: .. testcode:: # Configuration: config = MLPHeadConfig( input_dims=[4], # must be 1D tensor hidden_layer_dims=[8, 8], ...
5
1
11
3
8
0
2
4.6
1
1
0
0
1
0
1
25
69
13
10
5
5
46
8
4
4
2
6
1
2
11,299
ray-project/ray
rllib/core/models/configs.py
rllib.core.models.configs.ModelConfig
from typing import Callable, Dict, List, Optional, Tuple, TYPE_CHECKING, Union import abc from ray.rllib.utils.annotations import ExperimentalAPI from dataclasses import dataclass, field @ExperimentalAPI @dataclass class ModelConfig(abc.ABC): """Base class for configuring a `Model` instance. ModelConfigs are ...
@ExperimentalAPI @dataclass class ModelConfig(abc.ABC): '''Base class for configuring a `Model` instance. ModelConfigs are DL framework-agnostic. A `Model` (as a sub-component of an `RLModule`) is built via calling the respective ModelConfig's `build()` method. RLModules build their sub-components t...
7
3
5
1
2
3
1
2.44
1
3
0
5
2
0
2
22
38
7
9
7
4
22
7
5
4
1
4
0
2