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,600
ray-project/ray
rllib/models/torch/modules/multi_head_attention.py
rllib.models.torch.modules.multi_head_attention.MultiHeadAttention
from ray.rllib.utils.framework import TensorType from ray.rllib.models.torch.misc import SlimFC from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.utils.torch_utils import sequence_mask @OldAPIStack class MultiHeadAttention(nn.Module): """A multi-head attention layer described in [1].""" def _...
@OldAPIStack class MultiHeadAttention(nn.Module): '''A multi-head attention layer described in [1].''' def __init__(self, in_dim: int, out_dim: int, num_heads: int, head_dim: int, **kwargs): ''' in_dim: Dimension of input out_dim: Dimension of output num_heads: Number of attenti...
4
2
26
5
17
7
1
0.41
1
3
0
0
2
4
2
2
55
11
34
20
29
14
28
18
25
1
1
0
2
11,601
ray-project/ray
rllib/models/torch/modules/noisy_layer.py
rllib.models.torch.modules.noisy_layer.NoisyLayer
import numpy as np from ray.rllib.models.utils import get_activation_fn from ray.rllib.utils.framework import try_import_torch, TensorType class NoisyLayer(nn.Module): """A Layer that adds learnable Noise to some previous layer's outputs. Consists of: - a common dense layer: y = w^{T}x + b - a noisy l...
class NoisyLayer(nn.Module): '''A Layer that adds learnable Noise to some previous layer's outputs. Consists of: - a common dense layer: y = w^{T}x + b - a noisy layer: y = (w + \epsilon_w*\sigma_w)^{T}x + (b+\epsilon_b*\sigma_b) , where \epsilon are random variables sampled from factorized...
4
2
26
2
21
2
2
0.25
1
4
0
0
3
4
3
3
91
10
65
19
59
16
28
17
24
2
1
1
5
11,602
ray-project/ray
rllib/models/torch/modules/relative_multi_head_attention.py
rllib.models.torch.modules.relative_multi_head_attention.RelativeMultiHeadAttention
from ray.rllib.utils.typing import TensorType from typing import Union from ray.rllib.models.torch.misc import SlimFC from ray.rllib.utils.torch_utils import sequence_mask class RelativeMultiHeadAttention(nn.Module): """A RelativeMultiHeadAttention layer as described in [3]. Uses segment level recurrence with...
class RelativeMultiHeadAttention(nn.Module): '''A RelativeMultiHeadAttention layer as described in [3]. Uses segment level recurrence with state reuse. ''' def __init__(self, in_dim: int, out_dim: int, num_heads: int, head_dim: int, input_layernorm: bool=False, output_activation: Union[str, callable]=...
5
2
41
7
24
11
2
0.49
1
6
1
0
2
9
3
3
131
24
74
38
60
36
53
28
49
2
1
1
5
11,603
ray-project/ray
rllib/models/torch/modules/relative_multi_head_attention.py
rllib.models.torch.modules.relative_multi_head_attention.RelativePositionEmbedding
from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class RelativePositionEmbedding(nn.Module): """Creates a [seq_length x seq_length] matrix for rel. pos encoding. Denoted as Phi in [2] and [3]. Phi is the standard sinusoid encoding matrix. Args: seq_length: The max. sequence le...
@OldAPIStack class RelativePositionEmbedding(nn.Module): '''Creates a [seq_length x seq_length] matrix for rel. pos encoding. Denoted as Phi in [2] and [3]. Phi is the standard sinusoid encoding matrix. Args: seq_length: The max. sequence length (time axis). out_dim: The number of nodes ...
4
1
8
1
8
0
1
0.63
1
1
0
0
2
1
2
2
32
6
16
9
13
10
12
9
9
1
1
0
2
11,604
ray-project/ray
rllib/models/torch/modules/skip_connection.py
rllib.models.torch.modules.skip_connection.SkipConnection
from typing import Optional from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.utils.typing import TensorType @OldAPIStack class SkipConnection(nn.Module): """Skip connection layer. Adds the original input to the output (regular residual layer) OR uses input as hidden state input to a give...
@OldAPIStack class SkipConnection(nn.Module): '''Skip connection layer. Adds the original input to the output (regular residual layer) OR uses input as hidden state input to a given fan_in_layer. ''' def __init__(self, layer: nn.Module, fan_in_layer: Optional[nn.Module]=None, **kwargs): '''...
4
2
13
1
7
6
2
1.07
1
1
0
0
2
2
2
2
34
5
14
8
9
15
11
6
8
2
1
1
3
11,605
ray-project/ray
rllib/models/torch/recurrent_net.py
rllib.models.torch.recurrent_net.LSTMWrapper
from ray.rllib.utils.torch_utils import flatten_inputs_to_1d_tensor, one_hot from ray.rllib.utils.spaces.space_utils import get_base_struct_from_space from gymnasium.spaces import Discrete, MultiDiscrete from typing import Dict, List, Union, Tuple import gymnasium as gym import tree from ray.rllib.utils.typing import M...
@OldAPIStack class LSTMWrapper(RecurrentNetwork, nn.Module): '''An LSTM wrapper serving as an interface for ModelV2s that set use_lstm.''' def __init__(self, obs_space: gym.spaces.Space, action_space: gym.spaces.Space, num_outputs: int, model_config: ModelConfigDict, name: str): pass @override(Recu...
11
1
31
3
21
8
4
0.36
2
3
0
0
5
12
5
7
169
18
111
43
87
40
59
24
53
10
2
3
19
11,606
ray-project/ray
rllib/models/torch/recurrent_net.py
rllib.models.torch.recurrent_net.RecurrentNetwork
from ray.rllib.models.modelv2 import ModelV2 from ray._common.deprecation import deprecation_warning from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.utils.annotations import OldAPIStack, override from ray.util.debug import log_once from typing import Dict, List, Union, Tuple from ray.rllib....
@OldAPIStack class RecurrentNetwork(TorchModelV2): '''Helper class to simplify implementing RNN models with TorchModelV2. Instead of implementing forward(), you can implement forward_rnn() which takes batches with the time dimension added already. Here is an example implementation for a subclass ``M...
5
3
27
2
13
12
2
2.19
1
2
0
1
2
1
2
2
99
13
27
15
16
59
12
7
9
2
1
1
3
11,607
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchBeta
import gymnasium as gym from ray.rllib.models.action_dist import ActionDistribution from math import log from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict from ray.rllib.utils.numpy import SMALL_NUMBER, MIN_LOG_NN_OUTPUT, MAX_LOG_NN_OUTPUT import numpy as np from ray.rllib.models.torch....
@OldAPIStack class TorchBeta(TorchDistributionWrapper): ''' A Beta distribution is defined on the interval [0, 1] and parameterized by shape parameters alpha and beta (also called concentration parameters). PDF(x; alpha, beta) = x**(alpha - 1) (1 - x)**(beta - 1) / Z with Z = Gamma(alpha) Gamma(...
14
1
5
0
5
1
1
0.29
1
3
0
0
6
5
7
13
57
8
38
28
17
11
25
16
17
1
2
0
7
11,608
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchCategorical
from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict import gymnasium as gym import numpy as np from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.models.action_dist import ActionDistribution @OldAPISt...
@OldAPIStack class TorchCategorical(TorchDistributionWrapper): '''Wrapper class for PyTorch Categorical distribution.''' @override(ActionDistribution) def __init__(self, inputs: List[TensorType], model: TorchModelV2=None, temperature: float=1.0): pass @override(ActionDistribution) def determ...
9
1
6
0
6
0
1
0.04
1
3
0
2
2
2
3
9
27
3
23
16
8
1
12
6
8
2
2
1
4
11,609
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchDeterministic
from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.annotations import OldAPIStack, override import gymnasium as gym from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict import numpy as np @OldAPIStack class TorchDeterministic(TorchDistributionWrapper): ""...
@OldAPIStack class TorchDeterministic(TorchDistributionWrapper): '''Action distribution that returns the input values directly. This is similar to DiagGaussian with standard deviation zero (thus only requiring the "mean" values as NN output). ''' @override(ActionDistribution) def deterministic_s...
11
1
3
0
3
0
1
0.25
1
1
0
0
3
0
4
10
25
5
16
11
4
4
9
5
4
1
2
0
4
11,610
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchDiagGaussian
from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 import gymnasium as gym from typing import Optional i...
@OldAPIStack class TorchDiagGaussian(TorchDistributionWrapper): '''Wrapper class for PyTorch Normal distribution.''' @override(ActionDistribution) def __init__(self, inputs: List[TensorType], model: TorchModelV2, *, action_space: Optional[gym.spaces.Space]=None): pass @override(TorchDistribution...
17
1
4
0
4
0
1
0.05
1
2
0
0
6
5
7
13
48
7
39
29
15
2
23
14
15
2
2
1
8
11,611
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchDirichlet
from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.annotations import OldAPIStack, override import numpy as np @OldAPIStack class TorchDirichlet(TorchDistributionWrapper): """Dirichlet distribution for ...
@OldAPIStack class TorchDirichlet(TorchDistributionWrapper): '''Dirichlet distribution for continuous actions that are between [0,1] and sum to 1. e.g. actions that represent resource allocation.''' def __init__(self, inputs, model): '''Input is a tensor of logits. The exponential of logits is ...
12
2
6
0
4
2
1
0.48
1
1
0
0
4
3
5
11
44
7
25
14
14
12
17
10
11
1
2
0
5
11,612
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchDistributionWrapper
from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.annotations import OldAPIStack, override @OldAPIStack class TorchDistributionWrapper(ActionDi...
@OldAPIStack class TorchDistributionWrapper(ActionDistribution): '''Wrapper class for torch.distributions.''' @override(ActionDistribution) def __init__(self, inputs: List[TensorType], model: TorchModelV2): pass @override(ActionDistribution) def logp(self, actions: TensorType) -> TensorType:...
14
1
4
0
3
1
1
0.15
1
1
0
8
6
1
6
6
36
6
26
14
13
4
20
8
13
3
1
2
8
11,613
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchMultiActionDistribution
from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.models.action_dist import ActionDistribution import tree import numpy as np import functools from ray.rllib.utils.spaces.space_utils import get_base_struct_from_space from ray.rllib.utils.annotations import OldAPIStack, override @OldAPIStack ...
@OldAPIStack class TorchMultiActionDistribution(TorchDistributionWrapper): '''Action distribution that operates on multiple, possibly nested actions.''' def __init__(self, inputs, model, *, child_distributions, input_lens, action_space): '''Initializes a TorchMultiActionDistribution object. Arg...
18
2
12
1
9
2
2
0.27
1
6
2
0
8
3
8
14
117
14
81
33
64
22
52
26
42
7
2
4
20
11,614
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchMultiCategorical
from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict import gymnasium as gym from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.utils.annotations import OldAPIStack, override import numpy as np from ray.rllib.models.action_dist import ActionDistribution @OldAPISt...
@OldAPIStack class TorchMultiCategorical(TorchDistributionWrapper): '''MultiCategorical distribution for MultiDiscrete action spaces.''' @override(TorchDistributionWrapper) def __init__(self, inputs: List[TensorType], model: TorchModelV2, input_lens: Union[List[int], np.ndarray, Tuple[int, ...]], action_spa...
21
1
8
0
7
1
2
0.09
1
5
0
0
8
3
9
15
90
9
74
38
46
7
44
21
34
3
2
2
14
11,615
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchSlateMultiCategorical
from typing import Optional from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 import gymnasium as gym from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict from ray.rllib.utils.annotations import OldAPIStack, override ...
@OldAPIStack class TorchSlateMultiCategorical(TorchCategorical): '''MultiCategorical distribution for MultiDiscrete action spaces. The action space must be uniform, meaning all nvec items have the same size, e.g. MultiDiscrete([10, 10, 10]), where 10 is the number of candidates to pick from and 3 is the...
7
1
9
0
7
2
1
0.57
1
2
0
0
3
2
3
12
40
4
23
16
10
13
12
7
8
1
3
0
3
11,616
ray-project/ray
rllib/models/torch/torch_action_dist.py
rllib.models.torch.torch_action_dist.TorchSquashedGaussian
from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.annotations import OldAPIStack, override import numpy as np from ray.rllib.utils.typing import TensorType, List, Union, Tuple, ModelConfigDict from ray.rllib.utils.numpy import ...
@OldAPIStack class TorchSquashedGaussian(TorchDistributionWrapper): '''A tanh-squashed Gaussian distribution defined by: mean, std, low, high. The distribution will never return low or high exactly, but `low`+SMALL_NUMBER or `high`-SMALL_NUMBER respectively. ''' def __init__(self, inputs: List[Tens...
19
2
8
0
6
2
1
0.3
1
4
0
0
9
7
10
16
103
13
69
44
43
21
45
30
34
1
2
0
10
11,617
ray-project/ray
rllib/models/torch/torch_modelv2.py
rllib.models.torch.torch_modelv2.TorchModelV2
from ray.rllib.utils.typing import ModelConfigDict, TensorType from ray.rllib.utils.annotations import OldAPIStack, override import gymnasium as gym from typing import Dict, List, Union from ray.rllib.models.modelv2 import ModelV2 @OldAPIStack class TorchModelV2(ModelV2): """Torch version of ModelV2. Note tha...
@OldAPIStack class TorchModelV2(ModelV2): '''Torch version of ModelV2. Note that this class by itself is not a valid model unless you inherit from nn.Module and implement forward() in a subclass.''' def __init__(self, obs_space: gym.spaces.Space, action_space: gym.spaces.Space, num_outputs: int, mo...
7
2
19
1
13
5
2
0.46
1
6
0
0
3
1
3
3
68
8
41
19
24
19
15
6
11
2
1
1
6
11,618
ray-project/ray
rllib/models/torch/visionnet.py
rllib.models.torch.visionnet.VisionNetwork
from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 import numpy as np from ray.rllib.utils.annotations import OldAPIStack, override import gymnasium as gym from typing import Dict, List from ray.rllib.models.torch.misc import normc_initializer, same_padding, SlimConv2d, SlimFC from ray.rllib.utils.typing imp...
@OldAPIStack class VisionNetwork(TorchModelV2, nn.Module): '''Generic vision network.''' def __init__(self, obs_space: gym.spaces.Space, action_space: gym.spaces.Space, num_outputs: int, model_config: ModelConfigDict, name: str): pass @override(TorchModelV2) def forward(self, input_dict: Dict[s...
8
1
66
5
55
7
6
0.12
2
5
0
0
4
7
4
4
273
25
224
47
205
27
100
33
95
14
1
4
24
11,619
ray-project/ray
rllib/offline/d4rl_reader.py
rllib.offline.d4rl_reader.D4RLReader
from ray.rllib.offline.io_context import IOContext from ray.rllib.utils.typing import SampleBatchType from ray.rllib.utils.annotations import override, PublicAPI from ray.rllib.offline.input_reader import InputReader import gymnasium as gym @PublicAPI class D4RLReader(InputReader): """Reader object that loads the ...
@PublicAPI class D4RLReader(InputReader): '''Reader object that loads the dataset from the D4RL dataset.''' @PublicAPI def __init__(self, inputs: str, ioctx: IOContext=None): '''Initializes a D4RLReader instance. Args: inputs: String corresponding to the D4RL environment name. ...
6
2
10
2
6
3
2
0.43
1
1
0
0
2
3
2
2
25
5
14
9
8
6
12
7
8
2
1
1
3
11,620
ray-project/ray
rllib/offline/dataset_reader.py
rllib.offline.dataset_reader.DatasetReader
import ray.data import numpy as np from ray.rllib.utils.typing import SampleBatchType from typing import List, Tuple, TYPE_CHECKING, Optional from ray.rllib.offline.io_context import IOContext from ray.rllib.utils.annotations import override, PublicAPI from ray.rllib.offline.input_reader import InputReader from ray.rll...
@PublicAPI class DatasetReader(InputReader): '''Reader object that loads data from Ray Dataset. Examples: config = { "input": "dataset", "input_config": { "format": "json", # A single data file, a directory, or anything # that ray.d...
9
2
18
1
14
3
4
0.42
1
3
2
0
4
9
4
4
111
10
71
25
63
30
56
23
50
6
1
3
19
11,621
ray-project/ray
rllib/offline/dataset_writer.py
rllib.offline.dataset_writer.DatasetWriter
from ray.rllib.utils.typing import SampleBatchType from ray.rllib.offline.io_context import IOContext import os from ray.rllib.offline.output_writer import OutputWriter import time from ray import data from ray.rllib.offline.json_writer import _to_json_dict from ray.rllib.utils.annotations import override, PublicAPI fr...
@PublicAPI class DatasetWriter(OutputWriter): '''Writer object that saves experiences using Datasets.''' @PublicAPI def __init__(self, ioctx: IOContext=None, compress_columns: List[str]=frozenset(['obs', 'new_obs'])): '''Initializes a DatasetWriter instance. Examples: config = { ...
6
2
30
4
18
9
3
0.46
1
3
0
0
2
6
2
2
66
9
39
19
30
18
23
13
20
4
1
2
6
11,622
ray-project/ray
rllib/offline/estimators/direct_method.py
rllib.offline.estimators.direct_method.DirectMethod
import math from ray.rllib.utils.typing import SampleBatchType from ray.rllib.policy import Policy from ray.rllib.policy.sample_batch import convert_ma_batch_to_sample_batch from ray.rllib.offline.offline_evaluation_utils import compute_q_and_v_values from ray.rllib.offline.estimators.off_policy_estimator import OffPol...
@DeveloperAPI class DirectMethod(OffPolicyEstimator): '''The Direct Method estimator. Let s_t, a_t, and r_t be the state, action, and reward at timestep t. This method trains a Q-model for the evaluation policy \pi_e on behavior data generated by \pi_b. Currently, RLlib implements this using Fitted-...
13
4
22
3
13
6
1
0.59
1
6
0
0
6
1
6
6
158
28
82
41
60
48
43
26
36
2
1
1
8
11,623
ray-project/ray
rllib/offline/estimators/doubly_robust.py
rllib.offline.estimators.doubly_robust.DoublyRobust
from typing import Dict, Any, Optional, List from ray.rllib.offline.estimators.fqe_torch_model import FQETorchModel import numpy as np from ray.rllib.utils.numpy import convert_to_numpy import math from ray.rllib.offline.offline_evaluator import OfflineEvaluator import pandas as pd from ray.rllib.utils.annotations impo...
@DeveloperAPI class DoublyRobust(OffPolicyEstimator): '''The Doubly Robust estimator. Let s_t, a_t, and r_t be the state, action, and reward at timestep t. This method trains a Q-model for the evaluation policy \pi_e on behavior data generated by \pi_b. Currently, RLlib implements this using Fitted-...
13
4
33
5
21
8
1
0.52
1
8
0
0
5
4
5
5
226
39
123
53
100
64
65
37
58
2
1
1
8
11,624
ray-project/ray
rllib/offline/estimators/fqe_torch_model.py
rllib.offline.estimators.fqe_torch_model.FQETorchModel
from ray.rllib.utils.typing import ModelConfigDict, TensorType from typing import Dict, Any from ray.rllib.utils.annotations import DeveloperAPI from ray.rllib.models.catalog import ModelCatalog from ray.rllib.models.utils import get_initializer from ray.rllib.utils.annotations import is_overridden from gymnasium.space...
@DeveloperAPI class FQETorchModel: '''Pytorch implementation of the Fitted Q-Evaluation (FQE) model from https://arxiv.org/abs/1911.06854 ''' def __init__(self, policy: Policy, gamma: float, model_config: ModelConfigDict=None, n_iters: int=1, lr: float=0.001, min_loss_threshold: float=0.0001, clip_grad...
13
7
27
2
20
6
2
0.3
0
6
0
0
8
16
9
9
278
26
194
76
171
58
113
64
102
4
0
3
17
11,625
ray-project/ray
rllib/offline/estimators/importance_sampling.py
rllib.offline.estimators.importance_sampling.ImportanceSampling
from ray.data import Dataset from ray.rllib.policy.sample_batch import SampleBatch from typing import Dict, List, Any from ray.rllib.utils.annotations import override, DeveloperAPI from ray.rllib.offline.offline_evaluator import OfflineEvaluator import math from ray.rllib.offline.estimators.off_policy_estimator import ...
@DeveloperAPI class ImportanceSampling(OffPolicyEstimator): '''The step-wise IS estimator. Let s_t, a_t, and r_t be the state, action, and reward at timestep t. For behavior policy \pi_b and evaluation policy \pi_e, define the cumulative importance ratio at timestep t as: p_t = \sum_{t'=0}^t (\pi_e(...
8
2
30
4
20
6
2
0.43
1
5
0
0
3
0
3
3
110
20
63
31
52
27
38
24
34
4
1
2
6
11,626
ray-project/ray
rllib/offline/estimators/off_policy_estimator.py
rllib.offline.estimators.off_policy_estimator.OffPolicyEstimator
from ray.rllib.policy.sample_batch import convert_ma_batch_to_sample_batch from ray._common.deprecation import Deprecated from ray.rllib.utils.policy import compute_log_likelihoods_from_input_dict from ray.rllib.utils.annotations import DeveloperAPI, ExperimentalAPI, OverrideToImplementCustomLogic from ray.rllib.utils....
@DeveloperAPI class OffPolicyEstimator(OfflineEvaluator): '''Interface for an off policy estimator for counterfactual evaluation.''' @DeveloperAPI def __init__(self, policy: Policy, gamma: float=0.0, epsilon_greedy: float=0.0): '''Initializes an OffPolicyEstimator instance. Args: ...
23
10
18
2
8
8
2
0.86
1
9
0
0
11
2
11
11
224
34
102
51
62
88
52
23
40
4
1
2
17
11,627
ray-project/ray
rllib/offline/estimators/weighted_importance_sampling.py
rllib.offline.estimators.weighted_importance_sampling.WeightedImportanceSampling
from ray.rllib.policy.sample_batch import SampleBatch import math from ray.rllib.policy import Policy import numpy as np from ray.rllib.utils.annotations import override, DeveloperAPI from typing import Dict, Any, List from ray.data import Dataset from ray.rllib.offline.estimators.off_policy_estimator import OffPolicyE...
@DeveloperAPI class WeightedImportanceSampling(OffPolicyEstimator): '''The step-wise WIS estimator. Let s_t, a_t, and r_t be the state, action, and reward at timestep t. For behavior policy \pi_b and evaluation policy \pi_e, define the cumulative importance ratio at timestep t as: p_t = \sum_{t'=0}^...
14
2
23
3
17
4
2
0.31
1
8
0
0
6
3
6
6
167
26
108
49
89
33
68
37
61
6
1
2
13
11,628
ray-project/ray
rllib/offline/feature_importance.py
rllib.offline.feature_importance.FeatureImportance
import numpy as np from ray.rllib.utils.annotations import override, DeveloperAPI, ExperimentalAPI from ray.rllib.offline.offline_evaluator import OfflineEvaluator from ray.rllib.policy import Policy from ray.rllib.utils.typing import SampleBatchType import copy from typing import Callable, Dict, Any import pandas as p...
@DeveloperAPI class FeatureImportance(OfflineEvaluator): @override(OfflineEvaluator) def __init__(self, policy: Policy, repeat: int=1, limit_fraction: float=1.0, perturb_fn: Callable[[pd.DataFrame, int], pd.DataFrame]=_perturb_df): '''Feature importance in a model inspection technique that can be used ...
7
3
51
7
21
23
2
1.08
1
6
0
0
3
3
3
3
159
24
65
38
51
70
37
28
33
3
1
2
6
11,629
ray-project/ray
rllib/offline/input_reader.py
rllib.offline.input_reader.InputReader
from ray.rllib.utils.annotations import PublicAPI from ray.rllib.utils.typing import TensorType, SampleBatchType from typing import Dict, List from ray.rllib.policy.sample_batch import MultiAgentBatch import numpy as np from abc import ABCMeta, abstractmethod @PublicAPI class InputReader(metaclass=ABCMeta): """API...
@PublicAPI class InputReader(metaclass=ABCMeta): '''API for collecting and returning experiences during policy evaluation.''' @abstractmethod @PublicAPI def next(self) -> SampleBatchType: '''Returns the next batch of read experiences. Returns: The experience read (SampleBatch...
7
3
38
7
15
17
2
1.06
1
5
1
0
2
1
2
22
83
15
33
13
27
35
21
11
18
3
3
1
4
11,630
ray-project/ray
rllib/offline/input_reader.py
rllib.offline.input_reader._QueueRunner
import threading from typing import Dict, List from ray.rllib.utils.typing import TensorType, SampleBatchType class _QueueRunner(threading.Thread): """Thread that feeds a TF queue from a InputReader.""" def __init__(self, input_reader: InputReader, queue: 'tf1.FIFOQueue', keys: List[str], dtypes: 'tf.dtypes.D...
class _QueueRunner(threading.Thread): '''Thread that feeds a TF queue from a InputReader.''' def __init__(self, input_reader: InputReader, queue: 'tf1.FIFOQueue', keys: List[str], dtypes: 'tf.dtypes.DType'): pass def enqueue(self, batch: SampleBatchType): pass def run(self): ...
4
1
8
0
8
0
2
0.04
1
6
1
0
3
7
3
28
30
3
26
19
16
1
20
13
16
3
1
2
5
11,631
ray-project/ray
rllib/offline/io_context.py
rllib.offline.io_context.IOContext
import os from ray.rllib.utils.annotations import PublicAPI from typing import Optional, TYPE_CHECKING @PublicAPI class IOContext: """Class containing attributes to pass to input/output class constructors. RLlib auto-sets these attributes when constructing input/output classes, such as InputReaders and Ou...
@PublicAPI class IOContext: '''Class containing attributes to pass to input/output class constructors. RLlib auto-sets these attributes when constructing input/output classes, such as InputReaders and OutputWriters. ''' @PublicAPI def __init__(self, log_dir: Optional[str]=None, config: Optional[...
12
3
11
1
5
5
1
0.89
0
2
0
0
4
4
4
4
60
9
27
20
9
24
13
10
7
1
0
0
4
11,632
ray-project/ray
rllib/offline/is_estimator.py
rllib.offline.is_estimator.ImportanceSamplingEstimator
from ray._common.deprecation import Deprecated from ray.rllib.offline.estimators.importance_sampling import ImportanceSampling @Deprecated(new='ray.rllib.offline.estimators.importance_sampling::ImportanceSampling', error=True) class ImportanceSamplingEstimator(ImportanceSampling): pass
@Deprecated(new='ray.rllib.offline.estimators.importance_sampling::ImportanceSampling', error=True) class ImportanceSamplingEstimator(ImportanceSampling): 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,633
ray-project/ray
rllib/offline/json_reader.py
rllib.offline.json_reader.JsonReader
import random import math import zipfile import glob from ray.rllib.utils.typing import Any, FileType, SampleBatchType import re from typing import List, Optional, TYPE_CHECKING, Union import os from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID, MultiAgentBatch, SampleBatch, concat_samples, convert_ma_batch_t...
@PublicAPI class JsonReader(InputReader): '''Reader object that loads experiences from JSON file chunks. The input files will be read from in random order. ''' @PublicAPI def __init__(self, inputs: Union[str, List[str]], ioctx: Optional[IOContext]=None): '''Initializes a JsonReader instance....
13
3
22
1
18
3
5
0.16
1
10
0
0
9
6
9
9
212
23
164
41
150
27
131
36
121
11
1
3
44
11,634
ray-project/ray
rllib/offline/json_writer.py
rllib.offline.json_writer.JsonWriter
import time from ray.rllib.offline.io_context import IOContext from ray.rllib.offline.output_writer import OutputWriter from typing import Any, Dict, List from ray.rllib.utils.typing import FileType, SampleBatchType from urllib.parse import urlparse from ray.rllib.utils.annotations import override, PublicAPI import os ...
@PublicAPI class JsonWriter(OutputWriter): '''Writer object that saves experiences in JSON file chunks.''' @PublicAPI def __init__(self, path: str, ioctx: IOContext=None, max_file_size: int=64 * 1024 * 1024, compress_columns: List[str]=frozenset(['obs', 'new_obs'])): '''Initializes a JsonWriter inst...
7
2
24
1
20
3
3
0.16
1
5
0
0
3
8
3
3
78
5
64
25
52
10
41
17
37
5
1
3
9
11,635
ray-project/ray
rllib/offline/mixed_input.py
rllib.offline.mixed_input.MixedInput
from typing import Dict from ray.rllib.offline.input_reader import InputReader import numpy as np from ray.tune.registry import registry_get_input, registry_contains_input from ray.rllib.utils.annotations import override, DeveloperAPI from ray.rllib.utils.typing import SampleBatchType from types import FunctionType fro...
@DeveloperAPI class MixedInput(InputReader): '''Mixes input from a number of other input sources. .. testcode:: :skipif: True from ray.rllib.offline.io_context import IOContext from ray.rllib.offline.mixed_input import MixedInput ioctx = IOContext(...) MixedInput({ ...
6
2
13
1
10
3
4
0.82
1
3
0
0
2
2
2
2
45
5
22
10
17
18
17
8
14
6
1
2
7
11,636
ray-project/ray
rllib/offline/offline_data.py
rllib.offline.offline_data.OfflineData
from ray.rllib.utils import unflatten_dict from ray.rllib.env import INPUT_ENV_SPACES from ray.rllib.policy.sample_batch import MultiAgentBatch, SampleBatch from ray.util.annotations import PublicAPI from ray.rllib.offline.offline_prelearner import OfflinePreLearner from ray.rllib.core import COMPONENT_RL_MODULE from p...
@PublicAPI(stability='alpha') class OfflineData: @OverrideToImplementCustomLogic_CallToSuperRecommended def __init__(self, config: 'AlgorithmConfig'): pass @OverrideToImplementCustomLogic def sample(self, num_samples: int, return_iterator: bool=False, num_shards: int=1, module_state: Dict[str, ...
11
0
59
3
35
22
5
0.59
0
7
0
0
4
21
4
4
245
13
146
42
130
86
72
32
65
10
0
3
21
11,637
ray-project/ray
rllib/offline/offline_env_runner.py
rllib.offline.offline_env_runner.OfflineSingleAgentEnvRunner
from ray.util.annotations import PublicAPI from ray.rllib.core.columns import Columns from ray.rllib.algorithms.algorithm_config import AlgorithmConfig from pathlib import Path from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic_CallToSuperRecommended, OverrideToImplementCustomLogic from ra...
@PublicAPI(stability='alpha') class OfflineSingleAgentEnvRunner(SingleAgentEnvRunner): '''The environment runner to record the single agent case.''' @override(SingleAgentEnvRunner) @OverrideToImplementCustomLogic_CallToSuperRecommended def __init__(self, *, config: AlgorithmConfig, **kwargs): pa...
13
4
67
7
41
19
7
0.45
1
7
0
0
4
15
4
4
282
31
173
51
148
78
78
37
68
9
1
3
27
11,638
ray-project/ray
rllib/offline/offline_evaluator.py
rllib.offline.offline_evaluator.OfflineEvaluator
from ray.data import Dataset from typing import Dict, Any from ray.rllib.utils.typing import SampleBatchType from ray.rllib.policy import Policy import os import abc from ray.rllib.utils.annotations import DeveloperAPI, ExperimentalAPI @DeveloperAPI class OfflineEvaluator(abc.ABC): """Interface for an offline eval...
@DeveloperAPI class OfflineEvaluator(abc.ABC): '''Interface for an offline evaluator of a policy''' @DeveloperAPI def __init__(self, policy: Policy, **kwargs): '''Initializes an OffPolicyEstimator instance. Args: policy: Policy to evaluate. kwargs: forward compatibili...
11
5
13
2
3
8
1
1.72
1
4
0
0
4
1
4
24
62
13
18
15
3
31
8
6
3
1
4
0
4
11,639
ray-project/ray
rllib/offline/offline_prelearner.py
rllib.offline.offline_prelearner.OfflinePreLearner
from ray.rllib.utils.annotations import OverrideToImplementCustomLogic, OverrideToImplementCustomLogic_CallToSuperRecommended from typing import Any, Dict, List, Optional, Union, Set, Tuple, TYPE_CHECKING from ray.rllib.utils.typing import EpisodeType, ModuleID from ray.util.annotations import PublicAPI import gymnasiu...
@PublicAPI(stability='alpha') class OfflinePreLearner: '''Class that coordinates data transformation from dataset to learner. This class is an essential part of the new `Offline RL API` of `RLlib`. It is a callable class that is run in `ray.data.Dataset.map_batches` when iterating over batches for train...
19
8
61
4
38
19
6
0.55
0
11
0
0
6
11
8
8
588
46
350
70
302
192
102
37
89
19
0
3
51
11,640
ray-project/ray
rllib/offline/output_writer.py
rllib.offline.output_writer.NoopOutput
from ray.rllib.utils.annotations import override, PublicAPI from ray.rllib.utils.typing import SampleBatchType @PublicAPI class NoopOutput(OutputWriter): """Output writer that discards its outputs.""" @override(OutputWriter) def write(self, sample_batch: SampleBatchType): pass
@PublicAPI class NoopOutput(OutputWriter): '''Output writer that discards its outputs.''' @override(OutputWriter) def write(self, sample_batch: SampleBatchType): pass
4
1
3
0
2
1
1
0.5
1
0
0
0
1
0
1
2
7
1
4
3
1
2
3
2
1
1
1
0
1
11,641
ray-project/ray
rllib/offline/output_writer.py
rllib.offline.output_writer.OutputWriter
from ray.rllib.utils.typing import SampleBatchType from ray.rllib.utils.annotations import override, PublicAPI @PublicAPI class OutputWriter: """Writer API for saving experiences from policy evaluation.""" @PublicAPI def write(self, sample_batch: SampleBatchType): """Saves a batch of experiences. ...
@PublicAPI class OutputWriter: '''Writer API for saving experiences from policy evaluation.''' @PublicAPI def write(self, sample_batch: SampleBatchType): '''Saves a batch of experiences. Args: sample_batch: SampleBatch or MultiAgentBatch to save. ''' pass
4
2
7
1
2
4
1
1.25
0
1
0
1
1
0
1
1
11
2
4
3
1
5
3
2
1
1
0
0
1
11,642
ray-project/ray
rllib/offline/shuffled_input.py
rllib.offline.shuffled_input.ShuffledInput
from ray.rllib.offline.input_reader import InputReader import random from ray.rllib.utils.annotations import override, DeveloperAPI from ray.rllib.utils.typing import SampleBatchType @DeveloperAPI class ShuffledInput(InputReader): """Randomizes data over a sliding window buffer of N batches. This increases th...
@DeveloperAPI class ShuffledInput(InputReader): '''Randomizes data over a sliding window buffer of N batches. This increases the randomization of the data, which is useful if the batches were not in random order to start with. ''' @DeveloperAPI def __init__(self, child: InputReader, n: int=0): ...
6
2
11
1
8
3
3
0.5
1
1
0
0
2
3
2
2
31
4
18
9
13
9
16
7
13
4
1
2
5
11,643
ray-project/ray
rllib/offline/wis_estimator.py
rllib.offline.wis_estimator.WeightedImportanceSamplingEstimator
from ray.rllib.offline.estimators.weighted_importance_sampling import WeightedImportanceSampling from ray._common.deprecation import Deprecated @Deprecated(new='ray.rllib.offline.estimators.weighted_importance_sampling::WeightedImportanceSampling', error=True) class WeightedImportanceSamplingEstimator(WeightedImportan...
@Deprecated(new='ray.rllib.offline.estimators.weighted_importance_sampling::WeightedImportanceSampling', error=True) class WeightedImportanceSamplingEstimator(WeightedImportanceSampling): 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,644
ray-project/ray
rllib/policy/dynamic_tf_policy.py
rllib.policy.dynamic_tf_policy.DynamicTFPolicy
from ray.util.debug import log_once from collections import namedtuple, OrderedDict import gymnasium as gym from ray.rllib.utils.debug import summarize from ray.rllib.models.tf.tf_action_dist import TFActionDistribution from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.models.modelv2 import ModelV2 f...
@OldAPIStack class DynamicTFPolicy(TFPolicy): '''A TFPolicy that auto-defines placeholders dynamically at runtime. Do not sub-class this class directly (neither should you sub-class TFPolicy), but rather use rllib.policy.tf_policy_template.build_tf_policy to generate your custom tf (graph-mode or eager)...
17
4
94
6
69
19
10
0.29
1
14
1
0
9
24
9
9
871
66
626
144
559
180
247
84
237
31
1
5
89
11,645
ray-project/ray
rllib/policy/dynamic_tf_policy.py
rllib.policy.dynamic_tf_policy.TFMultiGPUTowerStack
from ray.util.debug import log_once from ray.rllib.policy.tf_policy import TFPolicy import tree from ray._common.deprecation import deprecation_warning, DEPRECATED_VALUE from typing import Callable, Dict, List, Optional, Tuple, Type, Union from ray.rllib.utils.typing import LocalOptimizer, ModelGradients, TensorType, A...
@OldAPIStack class TFMultiGPUTowerStack: '''Optimizer that runs in parallel across multiple local devices. TFMultiGPUTowerStack automatically splits up and loads training data onto specified local devices (e.g. GPUs) with `load_data()`. During a call to `optimize()`, the devices compute gradients over s...
7
4
71
7
51
13
7
0.31
0
4
0
0
5
16
5
5
380
45
258
67
242
79
144
57
138
18
0
4
36
11,646
ray-project/ray
rllib/policy/dynamic_tf_policy_v2.py
rllib.policy.dynamic_tf_policy_v2.DynamicTFPolicyV2
from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils import force_list from ray.rllib.utils.metrics.learner_info import LEARNER_STATS_KEY from ray.rllib.policy.dynamic_tf_policy import TFMultiGPUTowerStack from ray.rllib.policy.view_requirement import ViewRequirement from ray.rllib.policy.tf_polic...
@OldAPIStack class DynamicTFPolicyV2(TFPolicy): '''A TFPolicy that auto-defines placeholders dynamically at runtime. This class is intended to be used and extended by sub-classing. ''' def __init__(self, obs_space: gym.spaces.Space, action_space: gym.spaces.Space, config: AlgorithmConfigDict, *, ex...
62
19
28
2
19
7
3
0.33
1
13
0
0
32
22
33
33
1,001
111
670
195
552
221
285
106
251
24
1
4
103
11,647
ray-project/ray
rllib/policy/eager_tf_policy.py
rllib.policy.eager_tf_policy._OptimizerWrapper
class _OptimizerWrapper: def __init__(self, tape): self.tape = tape def compute_gradients(self, loss, var_list): return list(zip(self.tape.gradient(loss, var_list), var_list))
class _OptimizerWrapper: def __init__(self, tape): pass def compute_gradients(self, loss, var_list): pass
3
0
2
0
2
0
1
0
0
2
0
0
2
1
2
2
6
1
5
4
2
0
5
4
2
1
0
0
2
11,648
ray-project/ray
rllib/policy/eager_tf_policy_v2.py
rllib.policy.eager_tf_policy_v2.EagerTFPolicyV2
import gymnasium as gym from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.utils.typing import AlgorithmConfigDict, LocalOptimizer, ModelGradients, TensorType from ray.rllib.policy.rnn_sequencing import pad_batch_to_sequences_of_same_size from ray.util.debug import log_once from ray.rllib.utils.annotations imp...
@OldAPIStack class EagerTFPolicyV2(Policy): '''A TF-eager / TF2 based tensorflow policy. This class is intended to be used and extended by sub-classing. ''' def __init__(self, observation_space: gym.spaces.Space, action_space: gym.spaces.Space, config: AlgorithmConfigDict, **kwargs): pass ...
85
16
19
2
12
4
2
0.35
1
14
0
0
42
20
44
44
908
125
580
225
413
203
291
105
245
10
1
5
106
11,649
ray-project/ray
rllib/policy/policy.py
rllib.policy.policy.Policy
from abc import ABCMeta, abstractmethod import ray import platform from typing import Any, Callable, Collection, Dict, List, Optional, Tuple, Type, Union from ray.rllib.utils.annotations import OldAPIStack, OverrideToImplementCustomLogic, OverrideToImplementCustomLogic_CallToSuperRecommended, is_overridden from ray.rll...
null
52
43
33
3
17
13
3
0.79
1
16
3
0
41
17
43
63
1,482
194
723
225
588
568
365
135
316
32
3
5
138
11,650
ray-project/ray
rllib/policy/policy.py
rllib.policy.policy.PolicySpec
from ray.rllib.utils.annotations import OldAPIStack, OverrideToImplementCustomLogic, OverrideToImplementCustomLogic_CallToSuperRecommended, is_overridden from ray.rllib.utils.serialization import deserialize_type, space_from_dict, space_to_dict from typing import Any, Callable, Collection, Dict, List, Optional, Tuple, ...
@OldAPIStack class PolicySpec: '''A policy spec used in the "config.multiagent.policies" specification dict. As values (keys are the policy IDs (str)). E.g.: config: multiagent: policies: { "pol1": PolicySpec(None, Box, Discrete(2), {"lr": 0.0001}), "pol2"...
10
3
13
1
10
3
2
0.4
0
4
0
0
4
4
6
6
96
12
60
20
47
24
28
16
19
3
0
1
9
11,651
ray-project/ray
rllib/policy/policy_map.py
rllib.policy.policy_map.PolicyMap
import threading from ray.rllib.policy.policy import Policy from collections import deque from typing import Dict, Set from ray._common.deprecation import deprecation_warning from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.utils.typing import PolicyID from ray.rllib.utils.threading import w...
@OldAPIStack class PolicyMap(dict): '''Maps policy IDs to Policy objects. Thereby, keeps n policies in memory and - when capacity is reached - writes the least recently used to disk. This allows adding 100s of policies to a Algorithm for league-based setups w/o running out of memory. ''' def __...
40
9
14
2
8
4
2
0.48
1
8
0
0
14
7
15
42
276
46
155
62
106
75
105
39
86
6
2
2
38
11,652
ray-project/ray
rllib/policy/sample_batch.py
rllib.policy.sample_batch.MultiAgentBatch
from typing import List, Optional from ray._common.deprecation import Deprecated, deprecation_warning from ray.rllib.utils.typing import ModuleID, PolicyID, TensorType, SampleBatchType, ViewRequirementsDict import itertools from typing import Dict, Iterator, Set, Union from ray.rllib.utils.annotations import DeveloperA...
@PublicAPI class MultiAgentBatch: '''A batch of experiences from multiple agents in the environment. Attributes: policy_batches (Dict[PolicyID, SampleBatch]): Dict mapping policy IDs to SampleBatches of experiences. count: The number of env steps in this batch. ''' @PublicAPI...
35
14
12
1
7
4
2
0.6
0
7
1
0
14
2
16
16
241
38
127
62
78
76
75
36
55
7
0
2
30
11,653
ray-project/ray
rllib/policy/sample_batch.py
rllib.policy.sample_batch.SampleBatch
from typing import List, Optional import numpy as np from ray.rllib.utils.annotations import DeveloperAPI, ExperimentalAPI, PublicAPI from ray.rllib.utils.torch_utils import convert_to_torch_tensor from ray.util import log_once import tree from ray.rllib.utils.typing import ModuleID, PolicyID, TensorType, SampleBatchTy...
@PublicAPI class SampleBatch(dict): '''Wrapper around a dictionary with string keys and array-like values. For example, {"obs": [1, 2, 3], "reward": [0, -1, 1]} is a batch of three samples, each with an "obs" and "reward" attribute. ''' @PublicAPI def __init__(self, *args, **kwargs): '''...
75
29
29
4
16
9
3
0.58
1
16
1
0
35
13
36
63
1,246
188
673
223
577
388
450
172
407
13
2
5
144
11,654
ray-project/ray
rllib/policy/tf_mixins.py
rllib.policy.tf_mixins.EntropyCoeffSchedule
from ray.rllib.utils.framework import get_variable, try_import_tf from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.utils.schedules import PiecewiseSchedule @OldAPIStack class EntropyCoeffSchedule: """Mixin for TFPolicy that adds entropy coeff decay.""" def __init__(self, entropy_coeff, entro...
@OldAPIStack class EntropyCoeffSchedule: '''Mixin for TFPolicy that adds entropy coeff decay.''' def __init__(self, entropy_coeff, entropy_coeff_schedule): pass def on_global_var_update(self, global_vars): pass
4
1
23
1
22
1
4
0.07
0
2
0
0
2
4
2
2
50
3
44
8
41
3
19
8
16
4
0
2
7
11,655
ray-project/ray
rllib/policy/tf_mixins.py
rllib.policy.tf_mixins.GradStatsMixin
from ray.rllib.utils.annotations import OldAPIStack from typing import Dict, List from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.typing import AlgorithmConfigDict, LocalOptimizer, ModelGradients, TensorType @OldAPIStack class GradStatsMixin: def __init__(self): pass def gr...
@OldAPIStack class GradStatsMixin: def __init__(self): pass def grad_stats_fn(self, train_batch: SampleBatch, grads: ModelGradients) -> Dict[str, TensorType]: pass
4
0
8
1
6
2
2
0.23
0
1
0
0
2
0
2
2
18
2
13
6
8
3
8
4
5
2
0
1
3
11,656
ray-project/ray
rllib/policy/tf_mixins.py
rllib.policy.tf_mixins.KLCoeffMixin
from ray.rllib.utils.typing import AlgorithmConfigDict, LocalOptimizer, ModelGradients, TensorType from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.utils.framework import get_variable, try_import_tf from ray.rllib.policy.policy import PolicyState @OldAPIStack class KLCoeffMixin: """Assigns the `u...
@OldAPIStack class KLCoeffMixin: '''Assigns the `update_kl()` and other KL-related methods to a TFPolicy. This is used in Algorithms to update the KL coefficient after each learning step based on `config.kl_target` and the measured KL value (from the train_batch). ''' def __init__(self, config:...
7
1
12
1
8
3
2
0.45
0
2
0
0
5
5
5
5
70
9
42
12
36
19
27
12
21
3
0
1
9
11,657
ray-project/ray
rllib/policy/tf_mixins.py
rllib.policy.tf_mixins.LearningRateSchedule
from ray.rllib.utils.schedules import PiecewiseSchedule from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class LearningRateSchedule: """Mixin for TFPolicy that adds a learning rate schedule.""" def __init__(self, lr, lr_schedule): self._lr_schedule = None if lr_schedule is None...
@OldAPIStack class LearningRateSchedule: '''Mixin for TFPolicy that adds a learning rate schedule.''' def __init__(self, lr, lr_schedule): pass def on_global_var_update(self, global_vars): pass def optimizer(self): pass
5
1
11
0
11
1
3
0.09
0
1
0
0
3
4
3
3
39
3
33
9
29
3
22
9
18
3
0
2
8
11,658
ray-project/ray
rllib/policy/tf_mixins.py
rllib.policy.tf_mixins.TargetNetworkMixin
from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.policy.eager_tf_policy import EagerTFPolicy from typing import Dict, List import numpy as np from ray.rllib.utils.tf_utils import make_tf_callable from ray.rllib.utils.typing import AlgorithmConfigDict, LocalOptimizer, ModelGradients, TensorType from ra...
@OldAPIStack class TargetNetworkMixin: '''Assign the `update_target` method to the policy. The function is called every `target_network_update_freq` steps by the master learner. ''' def __init__(self): pass @make_tf_callable(self.get_session()) def update_target_fn(tau): ...
12
1
8
0
7
1
2
0.31
0
2
0
0
6
3
6
6
61
9
42
18
31
13
32
15
24
4
0
1
13
11,659
ray-project/ray
rllib/policy/tf_mixins.py
rllib.policy.tf_mixins.ValueNetworkMixin
from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.tf_utils import make_tf_callable from typing import Dict, List from ray.rllib.utils.typing import AlgorithmConfigDict, LocalOptimizer, ModelGradients, TensorType from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class ValueNetwor...
@OldAPIStack class ValueNetworkMixin: '''Assigns the `_value()` method to a TFPolicy. This way, Policy can call `_value()` to get the current VF estimate on a single(!) observation (as done in `postprocess_trajectory_fn`). Note: When doing this, an actual forward pass is being performed. This is dif...
9
1
15
1
9
5
2
0.92
0
2
0
0
3
3
3
3
78
9
36
14
28
33
28
12
22
3
0
1
10
11,660
ray-project/ray
rllib/policy/tf_policy.py
rllib.policy.tf_policy.TFPolicy
from ray.rllib.policy.policy import Policy, PolicyState, PolicySpec from ray._common.deprecation import Deprecated from ray.rllib.policy.rnn_sequencing import pad_batch_to_sequences_of_same_size from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.policy.sample_batch import SampleBatch from ray....
@OldAPIStack class TFPolicy(Policy): '''An agent policy and loss implemented in TensorFlow. Do not sub-class this class directly (neither should you sub-class DynamicTFPolicy), but rather use rllib.policy.tf_policy_template.build_tf_policy to generate your custom tf (graph-mode or eager) Policy clas...
65
23
24
2
16
6
3
0.4
1
16
1
0
42
38
44
44
1,158
157
718
255
575
287
403
155
356
14
1
4
140
11,661
ray-project/ray
rllib/policy/torch_mixins.py
rllib.policy.torch_mixins.EntropyCoeffSchedule
from ray.rllib.utils.schedules import PiecewiseSchedule from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class EntropyCoeffSchedule: """Mixin for TorchPolicy that adds entropy coeff decay.""" def __init__(self, entropy_coeff, entropy_coeff_schedule): self._entropy_coeff_schedule = None...
@OldAPIStack class EntropyCoeffSchedule: '''Mixin for TorchPolicy that adds entropy coeff decay.''' def __init__(self, entropy_coeff, entropy_coeff_schedule): pass def on_global_var_update(self, global_vars): pass
4
1
14
0
12
2
3
0.2
0
2
0
0
2
2
2
2
32
2
25
5
22
5
13
5
10
3
0
2
5
11,662
ray-project/ray
rllib/policy/torch_mixins.py
rllib.policy.torch_mixins.KLCoeffMixin
from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.policy.policy import PolicyState @OldAPIStack class KLCoeffMixin: """Assigns the `update_kl()` method to a TorchPolicy. This is used by Algorithms to update the KL coefficient after each learning step based on `config.kl_target` and th...
@OldAPIStack class KLCoeffMixin: '''Assigns the `update_kl()` method to a TorchPolicy. This is used by Algorithms to update the KL coefficient after each learning step based on `config.kl_target` and the measured KL value (from the train_batch). ''' def __init__(self, config): pass ...
6
1
6
0
4
2
2
0.71
0
1
0
0
4
2
4
4
34
5
17
8
12
12
16
8
11
3
0
1
6
11,663
ray-project/ray
rllib/policy/torch_mixins.py
rllib.policy.torch_mixins.LearningRateSchedule
from ray.rllib.utils.schedules import PiecewiseSchedule from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class LearningRateSchedule: """Mixin for TorchPolicy that adds a learning rate schedule.""" def __init__(self, lr, lr_schedule, lr2=None, lr2_schedule=None): self._lr_schedule = Non...
@OldAPIStack class LearningRateSchedule: '''Mixin for TorchPolicy that adds a learning rate schedule.''' def __init__(self, lr, lr_schedule, lr2=None, lr2_schedule=None): pass def on_global_var_update(self, global_vars): pass
4
1
16
0
15
1
5
0.1
0
1
0
0
2
4
2
2
36
2
31
9
28
3
25
9
22
6
0
3
9
11,664
ray-project/ray
rllib/policy/torch_mixins.py
rllib.policy.torch_mixins.TargetNetworkMixin
from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.policy.torch_policy import TorchPolicy @OldAPIStack class TargetNetworkMixin: """Mixin class adding a method for (soft) target net(s) synchronizations. - Adds the `update_target` method to the policy. Calling `update_target` updates all ...
@OldAPIStack class TargetNetworkMixin: '''Mixin class adding a method for (soft) target net(s) synchronizations. - Adds the `update_target` method to the policy. Calling `update_target` updates all target Q-networks' weights from their respective "main" Q-networks, based on tau (smooth, partial upda...
5
1
10
1
5
3
1
0.88
0
0
0
0
3
0
3
3
39
7
17
8
13
15
14
8
10
2
0
1
4
11,665
ray-project/ray
rllib/policy/torch_mixins.py
rllib.policy.torch_mixins.ValueNetworkMixin
from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class ValueNetworkMixin: """Assigns the `_value()` method to a TorchPolicy. This way, Policy can call `_value()` to get the current VF estimate on a single(!) observation (as done in `pos...
@OldAPIStack class ValueNetworkMixin: '''Assigns the `_value()` method to a TorchPolicy. This way, Policy can call `_value()` to get the current VF estimate on a single(!) observation (as done in `postprocess_trajectory_fn`). Note: When doing this, an actual forward pass is being performed. This is ...
6
2
13
2
6
6
1
2
0
0
0
0
2
1
2
2
57
9
16
7
11
32
13
7
8
2
0
1
5
11,666
ray-project/ray
rllib/policy/torch_policy.py
rllib.policy.torch_policy.DirectStepOptimizer
from ray.rllib.utils.annotations import OldAPIStack, override @OldAPIStack class DirectStepOptimizer: """Typesafe method for indicating `apply_gradients` can directly step the optimizers with in-place gradients. """ _instance = None def __new__(cls): if DirectStepOptimizer._instance is Non...
@OldAPIStack class DirectStepOptimizer: '''Typesafe method for indicating `apply_gradients` can directly step the optimizers with in-place gradients. ''' def __new__(cls): pass def __eq__(self, other): pass def __repr__(self): pass
5
1
3
0
3
0
1
0.3
0
2
0
0
3
0
3
3
17
4
10
5
6
3
10
5
6
2
0
1
4
11,667
ray-project/ray
rllib/policy/torch_policy.py
rllib.policy.torch_policy.TorchPolicy
import numpy as np from ray.rllib.utils.threading import with_lock from ray.rllib.utils.spaces.space_utils import normalize_action from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils import NullContextManager, force_list import copy from ray.rllib.models.torch.torch_action_dist import TorchDistri...
@OldAPIStack class TorchPolicy(Policy): '''PyTorch specific Policy class to use with RLlib.''' def __init__(self, observation_space: gym.spaces.Space, action_space: gym.spaces.Space, config: AlgorithmConfigDict, *, model: Optional[TorchModelV2]=None, loss: Optional[Callable[[Policy, ModelV2, Type[TorchDistribu...
53
12
40
4
27
9
4
0.34
1
16
0
0
28
25
28
28
1,118
131
737
241
605
253
383
137
352
16
1
7
126
11,668
ray-project/ray
rllib/policy/torch_policy_v2.py
rllib.policy.torch_policy_v2.TorchPolicyV2
import os from ray.rllib.policy.rnn_sequencing import pad_batch_to_sequences_of_same_size from ray.rllib.policy.policy import Policy import numpy as np from ray.rllib.utils.torch_utils import convert_to_torch_tensor, TORCH_COMPILE_REQUIRED_VERSION from ray.rllib.utils.spaces.space_utils import normalize_action from ray...
@OldAPIStack class TorchPolicyV2(Policy): '''PyTorch specific Policy class to use with RLlib.''' def __init__(self, observation_space: gym.spaces.Space, action_space: gym.spaces.Space, config: AlgorithmConfigDict, *, max_seq_len: int=20): '''Initializes a TorchPolicy instance. Args: ...
78
19
32
4
21
7
4
0.35
1
17
0
0
37
25
37
37
1,198
166
766
266
607
269
405
149
365
16
1
7
137
11,669
ray-project/ray
rllib/policy/view_requirement.py
rllib.policy.view_requirement.ViewRequirement
import numpy as np from ray.rllib.utils.serialization import gym_space_to_dict, gym_space_from_dict from ray.rllib.utils.annotations import OldAPIStack from typing import Dict, List, Optional, Union import dataclasses import gymnasium as gym @OldAPIStack @dataclasses.dataclass class ViewRequirement: """Single view...
@OldAPIStack @dataclasses.dataclass class ViewRequirement: '''Single view requirement (for one column in an SampleBatch/input_dict). Policies and ModelV2s return a Dict[str, ViewRequirement] upon calling their `[train|inference]_view_requirements()` methods, where the str key represents the column name ...
7
4
20
2
14
4
3
1.33
0
5
0
0
2
4
3
3
135
16
51
19
46
68
36
18
32
7
0
2
9
11,670
ray-project/ray
rllib/utils/__init__.py
rllib.utils.NullContextManager
from ray.rllib.utils.annotations import override, PublicAPI, DeveloperAPI import contextlib @DeveloperAPI class NullContextManager(contextlib.AbstractContextManager): """No-op context manager""" def __init__(self): pass def __enter__(self): pass def __exit__(self, *args): pas...
@DeveloperAPI class NullContextManager(contextlib.AbstractContextManager): '''No-op context manager''' def __init__(self): pass def __enter__(self): pass def __exit__(self, *args): pass
5
1
2
0
2
0
1
0.14
1
0
0
0
3
0
3
26
11
3
7
4
3
1
7
4
3
1
5
0
3
11,671
ray-project/ray
rllib/utils/actor_manager.py
rllib.utils.actor_manager.CallResult
from dataclasses import dataclass from ray.util.annotations import DeveloperAPI @DeveloperAPI @dataclass class CallResult: """Represents a single result from a call to an actor. Each CallResult contains the index of the actor that was called plus the result or error from the call. """ actor_id: in...
@DeveloperAPI @dataclass class CallResult: '''Represents a single result from a call to an actor. Each CallResult contains the index of the actor that was called plus the result or error from the call. ''' @property def ok(self): '''Passes through the ok property from the result_or_error...
6
3
3
0
2
1
1
0.67
0
0
0
0
2
0
2
2
19
4
9
4
5
6
8
3
5
1
0
0
2
11,672
ray-project/ray
rllib/utils/actor_manager.py
rllib.utils.actor_manager.FaultAwareApply
import sys import time from ray.util.annotations import DeveloperAPI from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union from ray.rllib.utils.typing import T @DeveloperAPI class FaultAwareApply: @DeveloperAPI def ping(self) -> str: """Ping the actor. Can be used as a health ...
null
6
2
20
2
9
10
2
0.95
0
3
0
0
2
0
2
2
44
5
20
11
10
19
12
3
9
3
0
2
4
11,673
ray-project/ray
rllib/utils/actor_manager.py
rllib.utils.actor_manager.FaultTolerantActorManager
from ray.util.annotations import DeveloperAPI from collections import defaultdict import ray from dataclasses import dataclass from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union from ray.actor import ActorHandle from ray.exceptions import RayError, RayTaskError @DeveloperAPI class FaultTole...
@DeveloperAPI class FaultTolerantActorManager: '''A manager that is aware of the healthiness of remote actors. .. testcode:: import time import ray from ray.rllib.utils.actor_manager import FaultTolerantActorManager @ray.remote class MyActor: def apply(self, f...
44
24
28
3
14
11
3
0.85
0
17
5
0
22
8
23
23
734
102
342
148
243
291
190
72
165
10
0
3
65
11,674
ray-project/ray
rllib/utils/actor_manager.py
rllib.utils.actor_manager.RemoteCallResults
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union import copy from ray.util.annotations import DeveloperAPI from ray.exceptions import RayError, RayTaskError @DeveloperAPI class RemoteCallResults: """Represents a list of results from calls to a set of actors. CallResults provides ...
@DeveloperAPI class RemoteCallResults: '''Represents a list of results from calls to a set of actors. CallResults provides convenient APIs to iterate over the results while skipping errors, etc. .. testcode:: :skipif: True manager = FaultTolerantActorManager( actors, max_remo...
12
6
4
0
2
2
1
1.21
0
6
4
0
6
1
6
6
69
16
24
13
13
29
22
13
11
2
0
1
10
11,675
ray-project/ray
rllib/utils/actor_manager.py
rllib.utils.actor_manager.ResultOrError
from ray.util.annotations import DeveloperAPI from ray.exceptions import RayError, RayTaskError from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union @DeveloperAPI class ResultOrError: """A wrapper around a result or a RayError thrown during remote task/actor calls. This is used to re...
@DeveloperAPI class ResultOrError: '''A wrapper around a result or a RayError thrown during remote task/actor calls. This is used to return data from `FaultTolerantActorManager` that allows us to distinguish between RayErrors (remote actor related) and valid results. ''' def __init__(self, result: ...
6
3
8
0
5
3
2
0.75
0
3
1
0
3
2
3
3
33
5
16
7
11
12
10
6
6
2
0
1
5
11,676
ray-project/ray
rllib/utils/actors.py
rllib.utils.actors.TaskPool
from collections import defaultdict, deque import ray class TaskPool: """Helper class for tracking the status of many in-flight actor tasks.""" def __init__(self): self._tasks = {} self._objects = {} self._fetching = deque() def add(self, worker, all_obj_refs): if isinstan...
class TaskPool: '''Helper class for tracking the status of many in-flight actor tasks.''' def __init__(self): pass def add(self, worker, all_obj_refs): pass def completed(self, blocking_wait=False): pass def completed_prefetch(self, blocking_wait=False, max_yield=999): ...
8
3
8
1
6
1
3
0.18
0
2
0
0
6
3
6
6
57
11
39
19
31
7
37
18
30
5
0
2
17
11,677
ray-project/ray
rllib/utils/checkpoints.py
rllib.utils.checkpoints.Checkpointable
from types import MappingProxyType from ray.rllib.utils import force_list from typing import Any, Collection, Dict, List, Optional, Tuple, Union from ray.rllib.utils.annotations import OldAPIStack, OverrideToImplementCustomLogic_CallToSuperRecommended import inspect import pyarrow.fs from ray.util.annotations import Pu...
@PublicAPI(stability='alpha') class Checkpointable(abc.ABC): '''Abstract base class for a component of RLlib that can be checkpointed to disk. Subclasses must implement the following APIs: - save_to_path() - restore_from_path() - from_checkpoint() - get_state() - set_state() - get_ctor_a...
22
10
41
5
22
14
4
0.73
1
10
0
0
10
0
11
31
612
84
305
106
245
224
166
64
144
15
4
4
57
11,678
ray-project/ray
rllib/utils/debug/summary.py
rllib.utils.debug.summary._StringValue
class _StringValue: def __init__(self, value): self.value = value def __repr__(self): return self.value
class _StringValue: def __init__(self, value): pass def __repr__(self): pass
3
0
2
0
2
0
1
0
0
0
0
0
2
1
2
2
6
1
5
4
2
0
5
4
2
1
0
0
2
11,679
ray-project/ray
rllib/utils/error.py
rllib.utils.error.EnvError
from ray.rllib.utils.annotations import PublicAPI @PublicAPI class EnvError(Exception): """Error if we encounter an error during RL environment validation.""" pass
@PublicAPI class EnvError(Exception): '''Error if we encounter an error during RL environment validation.''' pass
2
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
4
1
2
1
1
1
2
1
1
0
3
0
0
11,680
ray-project/ray
rllib/utils/error.py
rllib.utils.error.MultiAgentEnvError
from ray.rllib.utils.annotations import PublicAPI @PublicAPI class MultiAgentEnvError(Exception): """Error if we encounter an error during MultiAgentEnv stepping/validation.""" pass
@PublicAPI class MultiAgentEnvError(Exception): '''Error if we encounter an error during MultiAgentEnv stepping/validation.''' pass
2
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
4
1
2
1
1
1
2
1
1
0
3
0
0
11,681
ray-project/ray
rllib/utils/error.py
rllib.utils.error.NotSerializable
from ray.rllib.utils.annotations import PublicAPI @PublicAPI class NotSerializable(Exception): """Error if we encounter objects that can't be serialized by ray.""" pass
@PublicAPI class NotSerializable(Exception): '''Error if we encounter objects that can't be serialized by ray.''' pass
2
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
4
1
2
1
1
1
2
1
1
0
3
0
0
11,682
ray-project/ray
rllib/utils/error.py
rllib.utils.error.UnsupportedSpaceException
from ray.rllib.utils.annotations import PublicAPI @PublicAPI class UnsupportedSpaceException(Exception): """Error for an unsupported action or observation space.""" pass
@PublicAPI class UnsupportedSpaceException(Exception): '''Error for an unsupported action or observation space.''' pass
2
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
4
1
2
1
1
1
2
1
1
0
3
0
0
11,683
ray-project/ray
rllib/utils/exploration/curiosity.py
rllib.utils.exploration.curiosity.Curiosity
from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.utils.tf_utils import get_placeholder, one_hot as tf_one_hot from ray.rllib.utils.typing import FromConfigSpec, ModelConfigDict, TensorType from gymnasium.spaces import Discrete, MultiDiscrete, Space from ray.rllib.utils.from_config import fro...
@OldAPIStack class Curiosity(Exploration): '''Implementation of: [1] Curiosity-driven Exploration by Self-supervised Prediction Pathak, Agrawal, Efros, and Darrell - UC Berkeley - ICML 2017. https://arxiv.org/pdf/1705.05363.pdf Learns a simplified model of the environment based on three networks: ...
13
4
48
4
33
11
3
0.38
1
10
0
0
8
27
8
8
412
41
269
94
234
102
105
61
96
6
1
2
26
11,684
ray-project/ray
rllib/utils/exploration/epsilon_greedy.py
rllib.utils.exploration.epsilon_greedy.EpsilonGreedy
import random import gymnasium as gym from ray.rllib.models.torch.torch_action_dist import TorchMultiActionDistribution from ray.rllib.utils.numpy import convert_to_numpy from ray.rllib.utils.schedules import Schedule, PiecewiseSchedule from ray.rllib.utils.exploration.exploration import Exploration, TensorType from ra...
@OldAPIStack class EpsilonGreedy(Exploration): '''Epsilon-greedy Exploration class that produces exploration actions. When given a Model's output and a current epsilon value (based on some Schedule), it produces a random action (if rand(1) < eps) or uses the model-computed one (if rand(1) >= eps). '...
11
4
35
3
24
7
4
0.33
1
7
0
0
6
4
6
6
225
26
150
62
113
49
59
31
52
6
1
5
21
11,685
ray-project/ray
rllib/utils/exploration/exploration.py
rllib.utils.exploration.exploration.Exploration
from ray.rllib.utils.framework import try_import_torch, TensorType from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.typing import LocalOptimizer, AlgorithmConfigDict from ray.rllib.env.base_env import BaseEnv from ray.rllib.utils.annotations import OldAPIStack from ray.rllib.policy.sampl...
@OldAPIStack class Exploration: '''Implements an exploration strategy for Policies. An Exploration takes model outputs, a distribution, and a timestep from the agent and computes an action to apply to the environment using an implemented exploration schema. ''' def __init__(self, action_space: ...
11
10
18
2
8
9
1
1.3
0
5
0
0
9
7
9
9
188
27
70
59
19
91
29
18
19
3
0
2
11
11,686
ray-project/ray
rllib/utils/exploration/gaussian_noise.py
rllib.utils.exploration.gaussian_noise.GaussianNoise
from ray.rllib.utils.exploration.random import Random from ray.rllib.utils.numpy import convert_to_numpy import numpy as np from ray.rllib.utils.exploration.exploration import Exploration from ray.rllib.utils.schedules import Schedule from ray.rllib.utils.schedules.piecewise_schedule import PiecewiseSchedule from ray.r...
@OldAPIStack class GaussianNoise(Exploration): '''An exploration that adds white noise to continuous actions. If explore=True, returns actions plus scale (annealed over time) x Gaussian noise. Also, some completely random period is possible at the beginning. If explore=False, returns the determinist...
11
3
34
2
25
7
4
0.29
1
6
0
0
6
9
6
6
222
22
155
62
116
45
53
27
46
6
1
2
21
11,687
ray-project/ray
rllib/utils/exploration/ornstein_uhlenbeck_noise.py
rllib.utils.exploration.ornstein_uhlenbeck_noise.OrnsteinUhlenbeckNoise
from ray.rllib.utils.exploration.gaussian_noise import GaussianNoise from ray.rllib.utils.tf_utils import zero_logps_from_actions from typing import Optional, Union import numpy as np from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib...
@OldAPIStack class OrnsteinUhlenbeckNoise(GaussianNoise): '''An exploration that adds Ornstein-Uhlenbeck noise to continuous actions. If explore=True, returns sampled actions plus a noise term X, which changes according to this formula: Xt+1 = -theta*Xt + sigma*N[0,stddev], where theta, sigma and stddev...
11
3
47
3
35
9
4
0.28
1
6
0
0
5
7
5
5
252
21
181
64
147
51
65
34
59
7
1
2
20
11,688
ray-project/ray
rllib/utils/exploration/parameter_noise.py
rllib.utils.exploration.parameter_noise.ParameterNoise
from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.exploration.exploration import Exploration from ray.rllib.env.base_env import BaseEnv from gymnasium.spaces import Box, Discrete import numpy as np from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.torch.torch_action_dist import...
@OldAPIStack class ParameterNoise(Exploration): '''An exploration that changes a Model's parameters. Implemented based on: [1] https://openai.com/research/better-exploration-with-parameter-noise [2] https://arxiv.org/pdf/1706.01905.pdf At the beginning of an episode, Gaussian noise is added to all w...
25
7
24
2
16
5
3
0.35
1
11
0
0
16
14
16
16
412
49
270
94
211
95
139
48
122
10
1
2
54
11,689
ray-project/ray
rllib/utils/exploration/per_worker_epsilon_greedy.py
rllib.utils.exploration.per_worker_epsilon_greedy.PerWorkerEpsilonGreedy
from gymnasium.spaces import Space from ray.rllib.utils.schedules import ConstantSchedule from ray.rllib.utils.annotations import OldAPIStack from typing import Optional from ray.rllib.utils.exploration.epsilon_greedy import EpsilonGreedy @OldAPIStack class PerWorkerEpsilonGreedy(EpsilonGreedy): """A per-worker ep...
@OldAPIStack class PerWorkerEpsilonGreedy(EpsilonGreedy): '''A per-worker epsilon-greedy class for distributed algorithms. Sets the epsilon schedules of individual workers to a constant: 0.4 ^ (1 + [worker-index] / float([num-workers] - 1) * 7) See Ape-X paper. ''' def __init__(self, action_spa...
3
2
41
2
27
12
4
0.61
1
4
0
0
1
0
1
1
49
4
28
14
18
17
12
6
10
4
1
2
4
11,690
ray-project/ray
rllib/utils/exploration/per_worker_gaussian_noise.py
rllib.utils.exploration.per_worker_gaussian_noise.PerWorkerGaussianNoise
from ray.rllib.utils.schedules import ConstantSchedule from gymnasium.spaces import Space from ray.rllib.utils.exploration.gaussian_noise import GaussianNoise from typing import Optional from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class PerWorkerGaussianNoise(GaussianNoise): """A per-worker Ga...
@OldAPIStack class PerWorkerGaussianNoise(GaussianNoise): '''A per-worker Gaussian noise class for distributed algorithms. Sets the `scale` schedules of individual workers to a constant: 0.4 ^ (1 + [worker-index] / float([num-workers] - 1) * 7) See Ape-X paper. ''' def __init__(self, action_spa...
3
2
32
1
20
11
4
0.76
1
4
0
0
1
0
1
1
40
3
21
13
11
16
10
5
8
4
1
2
4
11,691
ray-project/ray
rllib/utils/exploration/per_worker_ornstein_uhlenbeck_noise.py
rllib.utils.exploration.per_worker_ornstein_uhlenbeck_noise.PerWorkerOrnsteinUhlenbeckNoise
from ray.rllib.utils.schedules import ConstantSchedule from gymnasium.spaces import Space from typing import Optional from ray.rllib.utils.exploration.ornstein_uhlenbeck_noise import OrnsteinUhlenbeckNoise from ray.rllib.utils.annotations import OldAPIStack @OldAPIStack class PerWorkerOrnsteinUhlenbeckNoise(OrnsteinUh...
@OldAPIStack class PerWorkerOrnsteinUhlenbeckNoise(OrnsteinUhlenbeckNoise): '''A per-worker Ornstein Uhlenbeck noise class for distributed algorithms. Sets the Gaussian `scale` schedules of individual workers to a constant: 0.4 ^ (1 + [worker-index] / float([num-workers] - 1) * 7) See Ape-X paper. '...
3
2
37
1
25
11
4
0.62
1
4
0
0
1
0
1
1
45
3
26
13
16
16
10
5
8
4
1
2
4
11,692
ray-project/ray
rllib/utils/exploration/random.py
rllib.utils.exploration.random.Random
from ray.rllib.utils import force_tuple from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.utils.exploration.exploration import Exploration from ray.rllib.utils.spaces.space_utils import get_base_struct_from_space from ray.rllib.models.action_dist import ActionDistribution import tree from ray.rllib.utils.spac...
@OldAPIStack class Random(Exploration): '''A random action selector (deterministic/greedy for explore=False). If explore=True, returns actions randomly from `self.action_space` (via Space.sample()). If explore=False, returns the greedy/max-likelihood action. ''' def __init__(self, action_space:...
10
2
37
2
33
3
2
0.15
1
5
0
0
4
2
4
4
148
13
117
36
94
18
44
20
36
6
1
3
17
11,693
ray-project/ray
rllib/utils/exploration/random_encoder.py
rllib.utils.exploration.random_encoder.RE3
from gymnasium.spaces import Box, Discrete, Space from typing import List, Optional, Union from ray.rllib.models.catalog import ModelCatalog from ray.rllib.policy.sample_batch import SampleBatch from ray.rllib.utils.exploration.exploration import Exploration from ray.rllib.utils.typing import FromConfigSpec, ModelConfi...
@OldAPIStack class RE3(Exploration): '''Random Encoder for Efficient Exploration. Implementation of: [1] State entropy maximization with random encoders for efficient exploration. Seo, Chen, Shin, Lee, Abbeel, & Lee, (2021). arXiv preprint arXiv:2102.09430. Estimates state entropy using a partic...
8
4
38
2
25
10
3
0.52
1
7
0
0
4
15
4
4
173
15
104
44
76
54
36
16
31
7
1
2
12
11,694
ray-project/ray
rllib/utils/exploration/random_encoder.py
rllib.utils.exploration.random_encoder._MovingMeanStd
from typing import List, Optional, Union import numpy as np class _MovingMeanStd: """Track moving mean, std and count.""" def __init__(self, epsilon: float=0.0001, shape: Optional[List[int]]=None): """Initialize object. Args: epsilon: Initial count. shape: Shape of the...
class _MovingMeanStd: '''Track moving mean, std and count.''' def __init__(self, epsilon: float=0.0001, shape: Optional[List[int]]=None): '''Initialize object. Args: epsilon: Initial count. shape: Shape of the trackables mean and std. ''' pass def _...
6
5
13
2
6
6
1
0.85
0
2
0
0
4
3
4
4
60
10
27
19
19
23
24
16
19
2
0
1
5
11,695
ray-project/ray
rllib/utils/exploration/slate_epsilon_greedy.py
rllib.utils.exploration.slate_epsilon_greedy.SlateEpsilonGreedy
from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.exploration.exploration import TensorType from typing import Union from ray.rllib.utils.exploration.epsilon_greedy import EpsilonGreedy from ray.rllib.utils.annotations import OldAPIStack, override @OldAPIStack class SlateEpsilonGreedy(Ep...
@OldAPIStack class SlateEpsilonGreedy(EpsilonGreedy): @override(EpsilonGreedy) def _get_tf_exploration_action_op(self, action_distribution: ActionDistribution, explore: Union[bool, TensorType], timestep: Union[int, TensorType]) -> 'tf.Tensor': pass @override(EpsilonGreedy) def _get_torch_explor...
6
0
49
7
38
4
3
0.1
1
2
0
0
2
1
2
2
101
14
79
38
64
8
35
26
32
4
1
2
6
11,696
ray-project/ray
rllib/utils/exploration/slate_soft_q.py
rllib.utils.exploration.slate_soft_q.SlateSoftQ
from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.utils.exploration.exploration import TensorType from ray.rllib.utils.exploration.soft_q import SoftQ from ray.rllib.models.action_dist import ActionDistribution from typing import Union @OldAPIStack class SlateSoftQ(SoftQ): @override(Sof...
@OldAPIStack class SlateSoftQ(SoftQ): @override(SoftQ) def get_exploration_action(self, action_distribution: ActionDistribution, timestep: Union[int, TensorType], explore: bool=True): pass
4
0
31
5
21
5
2
0.22
1
3
0
0
1
2
1
1
33
5
23
14
15
5
12
7
10
2
1
1
2
11,697
ray-project/ray
rllib/utils/exploration/soft_q.py
rllib.utils.exploration.soft_q.SoftQ
from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.exploration.stochastic_sampling import StochasticSampling from ray.rllib.models.tf.tf_action_dist import Categorical from gymnasium.spaces import Discrete, MultiDiscrete, Space from ray.rllib.models.torch.torch_action_dist import TorchCate...
@OldAPIStack class SoftQ(StochasticSampling): '''Special case of StochasticSampling w/ Categorical and temperature param. Returns a stochastic sample from a Categorical parameterized by the model output divided by the temperature. Returns the argmax iff explore=False. ''' def __init__(self, action_...
5
2
17
1
12
5
1
0.56
1
6
0
0
2
2
2
2
43
4
25
19
9
14
10
6
7
1
1
0
2
11,698
ray-project/ray
rllib/utils/exploration/stochastic_sampling.py
rllib.utils.exploration.stochastic_sampling.StochasticSampling
from ray.rllib.utils.framework import get_variable, try_import_tf, try_import_torch, TensorType from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.utils.tf_utils import zero_logps_from_actions import numpy as np import gymnasium as gym from ray.rlli...
@OldAPIStack class StochasticSampling(Exploration): '''An exploration that simply samples from a distribution. The sampling can be made deterministic by passing explore=False into the call to `get_exploration_action`. Also allows for scheduled parameters for the distributions, such as lowering stdde...
7
2
30
3
23
5
3
0.26
1
5
0
0
4
5
4
4
133
15
94
37
69
24
33
15
28
4
1
2
11
11,699
ray-project/ray
rllib/utils/exploration/thompson_sampling.py
rllib.utils.exploration.thompson_sampling.ThompsonSampling
from ray.rllib.utils.exploration.exploration import Exploration from ray.rllib.utils.annotations import OldAPIStack, override from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.utils.framework import TensorType, try_import_tf from typing import Union @OldAPIStack class ThompsonSampling(Explorat...
@OldAPIStack class ThompsonSampling(Exploration): @override(Exploration) def get_exploration_action(self, action_distribution: ActionDistribution, timestep: Union[int, TensorType], explore: bool=True): pass def _get_torch_exploration_action(self, action_dist, explore): pass def _get_t...
6
0
9
0
9
0
2
0
1
3
0
0
3
0
3
3
32
2
30
12
20
0
14
6
10
3
1
1
6