slideflow.model.torch¶
This submodule contains PyTorch-specific utility functions when working in the PyTorch backend.
- lazy_load_pretrained(module: Module, to_load: str) None [source]¶
Loads pretrained model weights into an existing module, ignoring incompatible Tensors.
- Parameters:
module (torch.nn.Module) – Destination module for weights.
to_load (str, torch.nn.Module) – Module with weights to load. Either path to PyTorch Slideflow model, or an existing PyTorch module.
- Returns:
None
- load(path: str) Module [source]¶
Load a model trained with Slideflow.
- Parameters:
path (str) – Path to saved model. Must be a model trained in Slideflow.
- Returns:
Loaded model.
- Return type:
torch.nn.Module
- log_manifest(train_tfrecords: List[str] | None = None, val_tfrecords: List[str] | None = None, *, labels: Dict[str, Any] | None = None, filename: str | None = None, remove_extension: bool = True) str [source]¶
Saves the training manifest in CSV format and returns as a string.
- Parameters:
- Keyword Arguments:
- Returns:
Saved manifest in str format.
- Return type: