Networks
Reference information for the model Networks
API.
eva.models.networks.MLP
Bases: Module
A Multi-layer Perceptron (MLP) network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_size |
int
|
The number of input features. |
required |
output_size |
int
|
The number of output features. |
required |
hidden_layer_sizes |
Tuple[int, ...] | None
|
A list specifying the number of units in each hidden layer. |
None
|
dropout |
float
|
Dropout probability for hidden layers. |
0.0
|
hidden_activation_fn |
Type[Module] | None
|
Activation function to use for hidden layers. Default is ReLU. |
ReLU
|
output_activation_fn |
Type[Module] | None
|
Activation function to use for the output layer. Default is None. |
None
|
Source code in src/eva/core/models/networks/mlp.py
forward
Defines the forward pass of the MLP.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Tensor
|
The input tensor. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
The output of the network. |
Wrappers
eva.models.wrappers.BaseModel
Bases: Module
Base class for model wrappers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tensor_transforms |
Callable | None
|
The transforms to apply to the output tensor produced by the model. |
None
|
Source code in src/eva/core/models/wrappers/base.py
load_model
abstractmethod
model_forward
Implements the forward pass of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tensor |
Tensor
|
The input tensor to the model. |
required |
eva.models.wrappers.ModelFromFunction
Bases: BaseModel
Wrapper class for models which are initialized from functions.
This is helpful for initializing models in a .yaml
configuration file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Callable[..., Module]
|
The path to the callable object (class or function). |
required |
arguments |
Dict[str, Any] | None
|
The extra callable function / class arguments. |
None
|
checkpoint_path |
str | None
|
The path to the checkpoint to load the model
weights from. This is currently only supported for torch
model checkpoints. For other formats, the checkpoint loading
should be handled within the provided callable object in |
None
|
tensor_transforms |
Callable | None
|
The transforms to apply to the output tensor produced by the model. |
None
|
Source code in src/eva/core/models/wrappers/from_function.py
eva.models.wrappers.HuggingFaceModel
Bases: BaseModel
Wrapper class for loading HuggingFace transformers
models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name_or_path |
str
|
The model name or path to load the model from.
This can be a local path or a model name from the |
required |
tensor_transforms |
Callable | None
|
The transforms to apply to the output tensor produced by the model. |
None
|
model_kwargs |
Dict[str, Any] | None
|
The arguments used for instantiating the model. |
None
|
Source code in src/eva/core/models/wrappers/huggingface.py
eva.models.wrappers.ONNXModel
Bases: BaseModel
Wrapper class for loading ONNX models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to the .onnx model file. |
required |
device |
Literal['cpu', 'cuda'] | None
|
The device to run the model on. This can be either "cpu" or "cuda". |
'cpu'
|
tensor_transforms |
Callable | None
|
The transforms to apply to the output tensor produced by the model. |
None
|