decent_bench.utils.types#

class NetworkT#

Type parameter bound to decent_bench.networks.Network.

Type definitions for optimization variables.

decent_bench.utils.types.ArrayLike#

Type alias for array-like types supported in decent-bench, including NumPy arrays, PyTorch tensors, TensorFlow tensors, and JAX arrays.

alias of numpy.ndarray | torch.Tensor | tf.Tensor | jax.Array

decent_bench.utils.types.SupportedArrayTypes#

Type alias for supported types for optimization variables in decent-bench, including array-like types and scalars.

alias of numpy.ndarray | torch.Tensor | tf.Tensor | jax.Array | float | int

type decent_bench.utils.types.InitialStates = Array | dict[Agent, Array] | None#

Type alias for what can be passed to initial_states().

type decent_bench.utils.types.LocalSteps = int | dict[Agent, int]#

Type alias for specifying local step counts in federated algorithms.

Can be a single positive integer shared by all clients, or a dictionary mapping each client agent to its own positive local step count.

decent_bench.utils.types.ArrayKey: TypeAlias = typing.SupportsIndex | slice | tuple[typing.SupportsIndex | slice, ...]#

Type alias for valid keys used to index into supported array types. Includes single indices, tuples of indices, slices, and tuples of slices.

type decent_bench.utils.types.EmpiricalRiskIndices = list[int] | Literal['all', 'batch'] | int#

Type alias for specifying indices in empirical risk computations. Can be a list of integers, the string “all” for full dataset, the string “batch” for a mini-batch, or an integer specifying a single datapoint.

type decent_bench.utils.types.EmpiricalRiskReduction = Literal['mean'] | None#

Type alias for specifying reduction methods in empirical risk computations. Can be “mean” to average over samples or None for no reduction and the result is returned as a list of gradients for each sample.

type decent_bench.utils.types.EmpiricalRiskBatchSize = int | Literal['all']#

Type alias for specifying batch size in empirical risk initialization. Can be an integer for mini-batch size or the string “all” for full dataset.

type decent_bench.utils.types.Datapoint = tuple[Array, Array]#

Tuple of (x, y) representing one datapoint where x are features and y is the target.

type decent_bench.utils.types.Dataset = list[Datapoint]#

List of datapoints, where each datapoint is a tuple of (features, targets).

In decentralized optimization each agent has their own local dataset. This type alias represents such datasets. This local dataset can be a subset of a larger global dataset or the entire dataset itself. These subsets can be obtained by using the DatasetHandler class, specifically the get_partitions() method.

Features and targets are represented as Array objects or framework-specific tensor objects in special cases. For unsupervised learning, targets are usually None.

The expected shapes depend on the specific dataset and cost function requirements, but typically it is:

  • Features: 1-dimensional vector (n_features,)

  • Targets: 1-dimensional vector (n_targets,), or None for unsupervised learning.

class decent_bench.utils.types.SupportedFrameworks(*values)[source]#

Bases: Enum

Enum for supported frameworks in decent-bench.

NUMPY = 'numpy'#
PYTORCH = 'pytorch'#
TENSORFLOW = 'tensorflow'#
JAX = 'jax'#
class decent_bench.utils.types.SupportedDevices(*values)[source]#

Bases: Enum

Enum for supported devices in decent-bench.

CPU = 'cpu'#
GPU = 'gpu'#
MPS = 'mps'#