Dropout Ensemble¶
- dattri.model_util.dropout.activate_dropout(model: torch.nn.Module, layer_positions: List[str] | None = None, dropout_prob: float = 0.1) torch.nn.Module ¶
Activate dropout layers in the model.
- Parameters:
model (torch.nn.Module) – The model to be used.
layer_positions (Optional[List[str]]) – Specific layer positions to activate dropouts. Should be a list of layer names. Default to all dropout layers found in the model.
dropout_prob (float) – The dropout probability to be applied. If not specified, it will be defaulted as 0.1.
- Raises:
ValueError – Some input layers do not contain nn.Dropout module.
- Returns:
The model with activated dropout layers.
- Return type:
torch.nn.Module