alibi_detect.utils.tensorflow.prediction module

alibi_detect.utils.tensorflow.prediction.predict_batch(x, model, batch_size=10000000000, dtype=numpy.float32)[source]

Make batch predictions on a model.

Parameters
  • x (Union[ndarray, Tensor]) – Batch of instances.

  • model (Model) – tf.keras model or one of the other permitted types defined in Data.

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

  • dtype (Union[float32, DType]) – Model output type, e.g. np.float32 or tf.float32.

Return type

Union[ndarray, Tensor]

Returns

Numpy array or tensorflow tensor with model outputs.

alibi_detect.utils.tensorflow.prediction.predict_batch_transformer(x, model, tokenizer, max_len, batch_size=10000000000, dtype=numpy.float32)[source]

Make batch predictions using a transformers tokenizer and model.

Parameters
  • x (ndarray) – Batch of instances.

  • model (Model) – Transformer model.

  • tokenizer – Tokenizer for model.

  • max_len (int) – Max token length.

  • batch_size (int) – Batch size.

Return type

Union[ndarray, Tensor]

Returns

Numpy array or tensorflow tensor with model outputs.