probly.transformation.subensemble

probly.transformation.subensemble(base, num_heads, head=None, reset_params=True, head_layer=1)[source]

Create a subensemble predictor from a base model or a base model and head model.

Supported configurations:
  1. base only:

    Head is created by extracting the last head_layer layers of base, while the remaining layers are used to create the backbone.

  2. base and head:

    base is used as the shared backbone, head is duplicated num_heads times to form the subensemble heads.

Parameters:
  • base (T) – Predictor, The model to be used as backbone or to create the backbone and heads.

  • num_heads (int) – int, The number of heads in the subensemble.

  • head (T | None) – Predictor, Optional model to be used as head of the subensemble.

  • reset_params (bool) – bool, Whether to reset the parameters of each head.

  • head_layer (int) – int, Optional the number of layers used to create the head if no head model is provided.

Returns:

Predictor, The subensemble predictor.

Raises:

ValueError – If head_layer or num_heads is not a positive integer.

Return type:

T