composer.types
This is our reference for common types used throughout our library.
Tensor Types
- class composer.types.Tensor
Alias for
torch.Tensor
- class composer.types.Tensors
Commonly used to represent e.g. a set of inputs, where it is unclear whether each input has its own tensor, or if all the inputs are concatenated in a single tensor.
Type:
torch.Tensor
, tuple oftorch.Tensor
s, or list oftorch.Tensor
s
Batch Types
A batch of data can be represented in several formats, depending on the application.
- class composer.types.Batch
Union type covering the most common representations of batches.
Type:
BatchPair
,BatchDict
, ortorch.Tensor
- class composer.types.BatchPair
Commonly used in computer vision tasks. The object is assumed to contain exactly two elements, where the first represents inputs and the second represents targets.
Type: List of
Tensors
- class composer.types.BatchDict
Commonly used in natural language processing tasks.
Type: str to
Tensor
dict
We provide helper functions to cast batches in situations where the batch type is known.
Dataset and Data Loader Types
- class composer.types.Dataset
Alias for
torch.utils.data.Dataset[Batch]
Trainer Types
- class composer.types.Metrics
Union type covering common formats for representing metrics.
Type:
Metric
orMetricCollection
- class composer.types.Optimizer
Alias for
torch.optim.Optimizer
- class composer.types.Optimizers
Union type for indeterminate amounts of optimizers.
- class composer.types.Scheduler
Alias for
torch.optim.lr_scheduler._LRScheduler
- class composer.types.Schedulers
Union type for indeterminate amounts of schedulers.
- class composer.types.Scaler
Alias for
torch.cuda.amp.grad_scaler.GradScaler
- class composer.types.Model
Alias for
torch.nn.Module
Miscellaneous Types
- class composer.types.ModelParameters
Type alias for model parameters used to initialize optimizers.
Type: List of
torch.Tensor
or list of str totorch.Tensor
dicts
- class composer.types.JSON
JSON data.
- class composer.types.TPrefetchFn
Type alias for prefetch functions used for initializing dataloaders.
- class composer.types.StateDict
Class for representing serialized data.
Type: dict with str keys.