PyTorch Models
DataEval uses PyTorch as its main backend for metrics that require neural networks. While these metrics can take in custom models, DataEval provides utility classes to create a seamless integration between custom models and DataEval’s metrics.
How-To Guides
Check out this how to to begin using the AETrainer class
DataEval API
Trainers
- class dataeval.models.torch.AETrainer(model: Module, device: str | device = 'auto', batch_size: int = 8)
- encode(dataset: Dataset) Tensor
Encode data through model if it has an encode attribute, otherwise passes data through model.forward
- Parameters:
dataset (Dataset) – Dataset containing images to be encoded by the model
- Returns:
Data encoded by the model
- Return type:
torch.Tensor
- eval(dataset: Dataset) float
Basic evaluation function for Autoencoder models for reconstruction tasks
Uses torch.optim.Adam and torch.nn.MSELoss as default hyperparameters
- Parameters:
dataset (Dataset) – Torch Dataset containing images in the first return position
- Returns:
Total reconstruction loss over all data
- Return type:
float
Note
- To replace this function with a custom function, do
AETrainer.eval = custom_function
- train(dataset: Dataset, epochs: int = 25) List[float]
Basic training function for Autoencoder models for reconstruction tasks
Uses torch.optim.Adam and torch.nn.MSELoss as default hyperparameters
- Parameters:
dataset (Dataset) – Torch Dataset containing images in the first return position
epochs (int, default 25) – Number of full training loops
Note
- To replace this function with a custom function, do
AETrainer.train = custom_function