1 CoralLayer
rri_metrics.CoralLayer(in_dim, num_classes, *, preinit_bias=True)CORAL output layer with shared weights and per-threshold biases.
1.1 This implements logits
logit_k = w^T x + b_k, k = 0..K-2
1.2 Methods
| Name | Description |
|---|---|
| forward | Compute threshold logits. |
| init_bin_values | Initialize (or re-initialize) monotone bin representatives u_k. |
| init_bias_from_priors | Initialize CORAL biases from class priors. |
| expected_from_probs | Compute expected continuous value using learnable bin values. |
| expected_from_logits | Convert logits to marginals and compute expected continuous value. |
| bin_value_regularizer | L2 penalty to keep learnable bin values close to target values. |
1.2.1 forward
rri_metrics.CoralLayer.forward(x)Compute threshold logits.
1.2.1.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| x | Tensor | Tensor["... in_dim"]. |
required |
1.2.1.2 Returns
| Name | Type | Description |
|---|---|---|
| Tensor | Tensor["... K-1"]. |
1.2.2 init_bin_values
rri_metrics.CoralLayer.init_bin_values(values, *, overwrite=False)Initialize (or re-initialize) monotone bin representatives u_k.
1.2.3 init_bias_from_priors
rri_metrics.CoralLayer.init_bias_from_priors(priors, *, overwrite=True)Initialize CORAL biases from class priors.
1.2.3.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| priors | Tensor | Tensor["K"] class priors that sum to 1. |
required |
| overwrite | bool | If True, overwrite the current bias values. | True |
1.2.4 expected_from_probs
rri_metrics.CoralLayer.expected_from_probs(probs)Compute expected continuous value using learnable bin values.
1.2.5 expected_from_logits
rri_metrics.CoralLayer.expected_from_logits(logits)Convert logits to marginals and compute expected continuous value.
1.2.6 bin_value_regularizer
rri_metrics.CoralLayer.bin_value_regularizer(target_values)L2 penalty to keep learnable bin values close to target values.