Modules
Reference information for the model Modules
API.
eva.models.modules.ModelModule
Bases: LightningModule
The base model module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metrics |
MetricsSchema | None
|
The metric groups to track. |
None
|
postprocess |
BatchPostProcess | None
|
A list of helper functions to apply after the loss and before the metrics calculation to the model predictions and targets. |
None
|
Source code in src/eva/core/models/modules/module.py
default_metrics: metrics_lib.MetricsSchema
property
The default metrics.
default_postprocess: batch_postprocess.BatchPostProcess
property
The default post-processes.
metrics_device: torch.device
property
Returns the device by which the metrics should be calculated.
We allocate the metrics to CPU when operating on single device, as it is much faster, but to GPU when employing multiple ones, as DDP strategy requires the metrics to be allocated to the module's GPU.
eva.models.modules.HeadModule
Bases: ModelModule
Neural Net Head Module for training on features.
It can be used for supervised (mini-batch) stochastic gradient descent downstream tasks such as classification, regression and segmentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
head |
Dict[str, Any] | MODEL_TYPE
|
The neural network that would be trained on the features.
If its a dictionary, it will be parsed to an object during the
|
required |
criterion |
Callable[..., Tensor]
|
The loss function to use. |
required |
backbone |
MODEL_TYPE | None
|
The feature extractor. If |
None
|
optimizer |
OptimizerCallable
|
The optimizer to use. |
Adam
|
lr_scheduler |
LRSchedulerCallable
|
The learning rate scheduler to use. |
ConstantLR
|
metrics |
MetricsSchema | None
|
The metric groups to track. |
None
|
postprocess |
BatchPostProcess | None
|
A list of helper functions to apply after the loss and before the metrics calculation to the model predictions and targets. |
None
|
Source code in src/eva/core/models/modules/head.py
eva.models.modules.InferenceModule
Bases: ModelModule
An lightweight model module to perform inference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backbone |
MODEL_TYPE
|
The network to be used for inference. |
required |