Component API Reference¶
dataset
¶
Dataset
¶
Bases: Dataset
Base class for all CVLab-Kit datasets.
This class uses InterfaceMeta to act as a wrapper around a PyTorch
Dataset instance. Subclasses should define a dataset attribute
in their __init__ method, which will be the target for attribute and
method delegation.
Source code in cvlabkit/component/base/dataset.py
__getitem__
abstractmethod
¶
Retrieves the item at the given index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
The index of the item to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The item at the specified index. |
__len__
abstractmethod
¶
Returns the total number of items in the dataset.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The total number of items. |
data_loader
¶
DataLoader
¶
Bases: DataLoader
Base class for all CVLab-Kit data loaders.
This class uses InterfaceMeta to act as a wrapper around a PyTorch
DataLoader instance. Subclasses should define a loader attribute
in their __init__ method, which will be the target for attribute and
method delegation.
Source code in cvlabkit/component/base/data_loader.py
__iter__
abstractmethod
¶
model
¶
Model
¶
Bases: Module
Abstract base class for all models.
Source code in cvlabkit/component/base/model.py
forward
abstractmethod
¶
Defines the forward pass of the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
The input tensor. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: The output tensor. |
loss
¶
Loss
¶
Bases: Module
Abstract base class for all loss functions.
This class defines the interface for loss components. When implementing a custom
loss, the forward method should be defined to accept the necessary tensors.
The framework distinguishes between losses based on the number of arguments
their forward method accepts.
Source code in cvlabkit/component/base/loss.py
forward
abstractmethod
¶
Computes the loss based on a variable number of input tensors.
The number and order of tensors depend on the specific loss function being implemented.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*inputs
|
Tensor
|
A sequence of tensors required for the loss
computation. Common patterns include:
- |
()
|
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: A scalar tensor representing the computed loss value. |
Source code in cvlabkit/component/base/loss.py
optimizer
¶
Optimizer
¶
Bases: Optimizer
Abstract base class for all optimizers.
Source code in cvlabkit/component/base/optimizer.py
step
abstractmethod
¶
transform
¶
Transform
¶
Abstract base class for all transforms.
Source code in cvlabkit/component/base/transform.py
__call__
abstractmethod
¶
Applies the transform to the given sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Any
|
The input data to transform. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The transformed data. |
metric
¶
Metric
¶
Abstract base class for all metrics.
Source code in cvlabkit/component/base/metric.py
update
abstractmethod
¶
Updates the metric's internal state with new data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Arbitrary keyword arguments representing the data to update the metric. |
{}
|
compute
abstractmethod
¶
Computes the final metric value(s).
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict[str, float]: A dictionary of metric names and their computed values. |
checkpoint
¶
Checkpoint
¶
Abstract base class for checkpointing functionalities.
Source code in cvlabkit/component/base/checkpoint.py
save
abstractmethod
¶
Saves the current state of the experiment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
dict[str, Any]
|
The state dictionary to save. |
required |
file_path
|
str
|
The path to the file where the state will be saved. |
required |
Source code in cvlabkit/component/base/checkpoint.py
load
abstractmethod
¶
Loads a previously saved state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
The path to the file from which the state will be loaded. |
required |
scheduler
¶
Scheduler
¶
Bases: _LRScheduler
Abstract base class for all learning rate schedulers.
Source code in cvlabkit/component/base/scheduler.py
sampler
¶
Sampler
¶
Bases: Sampler
Abstract base class for data samplers.
Source code in cvlabkit/component/base/sampler.py
__iter__
abstractmethod
¶
logger
¶
Logger
¶
Abstract base class for all loggers.
Source code in cvlabkit/component/base/logger.py
log_metrics
abstractmethod
¶
Logs a dictionary of metrics at a given step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
dict[str, float]
|
A dictionary of metric names and their values. |
required |
step
|
int
|
The current step or epoch number. |
required |
Source code in cvlabkit/component/base/logger.py
log_hyperparams
abstractmethod
¶
Logs a dictionary of hyperparameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict[str, Any]
|
A dictionary of hyperparameter names and their values. |
required |
solver
¶
Solver
¶
Abstract base class for differential equation solvers.
Solvers are used for ODE/SDE integration in generative models, neural ODEs, and other continuous-time systems.
Source code in cvlabkit/component/base/solver.py
__call__
abstractmethod
¶
Solve differential equation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args, **kwargs
|
Solver-specific inputs |
required |
Returns:
| Type | Description |
|---|---|
|
Solution of the differential equation |