def Interpretation( learn:Learner, dl:DataLoader, # `DataLoader` to run inference over losses:TensorBase, # Losses calculated from `dl` act:NoneType=None, # Activation function for prediction):
Interpretation base class, can be inherited for task specific Interpretation classes
Interpretation is a helper base class for exploring predictions from trained models. It can be inherited for task specific interpretation classes, such as ClassificationInterpretation. Interpretation is memory efficient and should be able to process any sized dataset, provided the hardware could train the same model.
Note
Interpretation is memory efficient due to generating inputs, predictions, targets, decoded outputs, and losses for each item on the fly, using batch processing where possible.
def from_learner( learn, # Model used to create interpretation ds_idx:int=1, # Index of `learn.dls` when `dl` is None dl:DataLoader=None, # `Dataloader` used to make predictions act:NoneType=None, # Override default or set prediction activation function):
def top_losses( k:int|None=None, # Return `k` losses, defaults to all largest:bool=True, # Sort losses by largest or smallest items:bool=False, # Whether to return input items):
k largest(/smallest) losses and indexes, defaulting to all losses.
With the default of k=None, top_losses will return the entire dataset’s losses. top_losses can optionally include the input items for each loss, which is usually a file path or Pandas DataFrame.
def plot_top_losses( k:int| collections.abc.MutableSequence, # Number of losses to plot largest:bool=True, # Sort losses by largest or smallest**kwargs):
Show k largest(/smallest) preds and losses. Implementation based on type dispatch
def ClassificationInterpretation( learn:Learner, dl:DataLoader, # `DataLoader` to run inference over losses:TensorBase, # Losses calculated from `dl` act:NoneType=None, # Activation function for prediction):
def SegmentationInterpretation( learn:Learner, dl:DataLoader, # `DataLoader` to run inference over losses:TensorBase, # Losses calculated from `dl` act:NoneType=None, # Activation function for prediction):