alibi_detect.cd.pytorch package

class alibi_detect.cd.pytorch.HiddenOutput(model, layer=-1)[source]

Bases: torch.nn.Module

forward(x)[source]
Return type

Tensor

alibi_detect.cd.pytorch.preprocess_drift(x, model, device=None, tokenizer=None, max_len=None, batch_size=10000000000, dtype=numpy.float32)[source]

Prediction function used for preprocessing step of drift detector.

Parameters
  • x (ndarray) – Batch of instances.

  • model (Union[Module, Sequential]) – Model used for preprocessing.

  • device (Optional[device]) – Device type used. The default None tries to use the GPU and falls back on CPU if needed. Can be specified by passing either torch.device(‘cuda’) or torch.device(‘cpu’).

  • tokenizer (Optional[Callable]) – Optional tokenizer for text drift.

  • max_len (Optional[int]) – Optional max token length for text drift.

  • batch_size (int) – Batch size used during prediction.

  • dtype (type) – Model output type, e.g. np.float32 or torch.float32.

Return type

Union[ndarray, Tensor]

Returns

Numpy array or torch tensor with predictions.