probly.method.subensemble¶
- probly.method.subensemble(base: Predictor[In, H], num_heads: int, head: Predictor[[H], Out] | None = None, reset_params: bool = True, head_layer: int = 1) SubensemblePredictor[In, Out][source]¶
Create a subensemble predictor from a base model or a base model and head model.
- Supported configurations:
- base only:
Head is created by extracting the last head_layer layers of base, while the remaining layers are used to create the backbone.
- base and head:
base is used as the shared backbone, head is duplicated num_heads times to form the subensemble heads.
- Parameters:
base – Predictor, The model to be used as backbone or to create the backbone and heads.
num_heads – int, The number of heads in the subensemble.
head – Predictor, Optional model to be used as head of the subensemble.
reset_params – bool, Whether to reset the parameters of each head.
head_layer – int, Optional the number of layers used to create the head if no head model is provided.
- Returns:
SubensemblePredictor, The subensemble predictor.
- Raises:
ValueError – If head_layer or num_heads is not a positive integer.