PyTorch Models
DAML uses PyTorch as its main backend for metrics that require neural networks. While these metrics can take in custom models, DAML provides utility classes to create a seamless integration between custom models and DAML’s metrics.
Tutorials
Check out this tutorial to begin using the AETrainer class
How To Guides
There are currently no how to’s for AETrainer. If there are scenarios that you want us to explain, contact us!
DAML API
Trainers
- class daml.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