incerto.ood.extract_features

incerto.ood.extract_features#

incerto.ood.extract_features(model, data_loader, layer_name='penultimate')[source]#

Extract features from a specific layer of the model.

Uses str.endswith matching on module names, consistent with the hook mechanism in Mahalanobis and KNN.

Parameters:
  • model (Module) – PyTorch model.

  • data_loader (DataLoader) – DataLoader containing input data.

  • layer_name (str) – Name (suffix) of layer to extract features from.

Return type:

Tensor

Returns:

Tensor of extracted features.