ConformalClsTHR#
- class torch_uncertainty.post_processing.ConformalClsTHR(alpha, model=None, ts_init_val=1.0, ts_lr=0.1, ts_max_iter=100, enable_ts=True, device=None)[source]#
Conformal prediction post-processing for calibrated models.
- Parameters:
alpha (
float) – The confidence level, meaning we allow \(1-\alpha\) error.model (
Module|None) – Model to be calibrated. Defaults toNone.ts_init_val (
float) – Initial value for the temperature. Defaults to1.0.ts_lr (
float) – Learning rate for the temperature scaling optimizer. Defaults to0.1.ts_max_iter (
int) – Maximum number of iterations for the temperature scaling optimizer. Defaults to100.enable_ts (
bool) – Whether to scale the logits. Defaults toTrue.device (
Union[Literal['cpu','cuda'],device,None]) – device. Defaults toNone.
Warning
This implementation only works in the multiclass setting. Raise an issue if binary is needed.
- Reference:
Code inspired by TorchCP.
- model_forward(inputs)#
Apply the model and return the scores.
- Return type:
Tensor