• Docs >
  • slideflow.model.torch
Shortcuts

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:
  • train_tfrecords (list(str)], optional) – List of training TFRecords. Defaults to None.

  • val_tfrecords (list(str)], optional) – List of validation TFRecords. Defaults to None.

Keyword Arguments:
  • labels (dict, optional) – TFRecord outcome labels. Defaults to None.

  • filename (str, optional) – Path to CSV file to save. Defaults to None.

  • remove_extension (bool, optional) – Remove file extension from slide names. Defaults to True.

Returns:

Saved manifest in str format.

Return type:

str