Added properties

This commit is contained in:
2026-07-03 00:10:13 +03:00
parent e57efde395
commit 21f0427fba
+113 -20
View File
@@ -288,26 +288,6 @@ The concrete form of each partial derivative depends on the choice of distributi
$\mathcal{F}$, and is derived for each instantiation in \Cref{sec:roll-instantiations}. $\mathcal{F}$, and is derived for each instantiation in \Cref{sec:roll-instantiations}.
\subsection{Properties of the ROLL Formulation}
\label{sec:roll-properties}
% State and prove (or sketch) key properties: consistency of the estimator as
% the number of samples grows, monotonicity of the loss with respect to the
% TPR/FPR trade-off, and behaviour at the constraint boundary. Discuss what
% guarantees ROLL provides and under what assumptions they hold.
% NOTE - these properties are auto-generated, consider suggestions.
\subsection{Gradient Computation and the Custom Backward Pass}
\label{sec:roll-backward}
% Because the distribution parameters are themselves functions of model scores
% (not fixed), the backward pass must differentiate through the distribution
% fitting step. Describe the custom autograd implementation: how gradients flow
% from the ROLL loss back through the distribution parameters to the model
% weights. Highlight where standard autograd would fail and what the manual
% backward pass does differently.
%------------------------------------------------ %------------------------------------------------
@@ -695,6 +675,107 @@ where $\tau = \hat{F}_0^{-1}(\alpha ; \mathcal{B}_0)$.
%------------------------------------------------ %------------------------------------------------
\subsection{Properties of the ROLL Formulation}
\label{sec:roll-properties}
% State and prove (or sketch) key properties: consistency of the estimator as
% the number of samples grows, monotonicity of the loss with respect to the
% TPR/FPR trade-off, and behaviour at the constraint boundary. Discuss what
% guarantees ROLL provides and under what assumptions they hold.
% NOTE - these properties are auto-generated, consider suggestions.
A structural consequence of the ROLL formulation is that gradient mass is automatically
balanced between the two classes, regardless of their relative sizes in the batch.
This stands in contrast to standard losses such as cross-entropy, where the total gradient
contribution from each class is proportional to its count, making heavy class imbalance
a direct source of biased updates. Therefor, instead of needing to compensate for this
with loss-weighting per-class, fitting updates are made based equally off the results
of both classes.
\begin{proposition}[Gradient balance]
\label{prop:gradient-balance}
Let $\mathcal{F}$ be any distribution family whose CDF estimator is translation-invariant,
meaning $\hat{F}_k(t\,;\,\mathbf{s}+\delta\mathbf{1}) = \hat{F}_k(t-\delta\,;\,\mathbf{s})$
for all $\delta \in \mathbb{R}$. Then for any batch $\mathcal{B} = \mathcal{B}_0 \cup \mathcal{B}_1$:
\begin{equation}
\sum_{\mathbf{x}_i \in \mathcal{B}_1}
\frac{\partial \mathcal{L}_{\emph{\text{ROLL-TPR@FPR}}}}{\partial f_\theta(\mathbf{x}_i)}
\;=\;
-\!\sum_{\mathbf{x}_i \in \mathcal{B}_0}
\frac{\partial \mathcal{L}_{\emph{\text{ROLL-TPR@FPR}}}}{\partial f_\theta(\mathbf{x}_i)}
\label{eq:grad-balance}
\end{equation}
with both sides equal in magnitude to $\dfrac{\partial \hat{F}_1(\tau)}{\partial \tau}$,
independently of $|\mathcal{B}_0|$ and $|\mathcal{B}_1|$.
\end{proposition}
\begin{proof}
We treat each class separately via a uniform-shift argument.
\medskip\noindent\textit{Sum over $\mathcal{B}_0$.}
From \Cref{eq:roll-gradient}, for $y_i = 0$:
\[
\frac{\partial \mathcal{L}}{\partial f_\theta(\mathbf{x}_i)}
= \frac{\partial \hat{F}_1(\tau)}{\partial \tau}
\cdot \frac{\partial \tau}{\partial f_\theta(\mathbf{x}_i)}
\]
We claim $\sum_{\mathbf{x}_i \in \mathcal{B}_0}\frac{\partial \tau}{\partial f_\theta(\mathbf{x}_i)} = 1$.
Shift all negative scores uniformly: $f_\theta(\mathbf{x}_i) \to f_\theta(\mathbf{x}_i) + \delta$ for
$\mathbf{x}_i \in \mathcal{B}_0$. By translation invariance, $\hat{F}_0$ simply translates, so
$\tau = \hat{F}_0^{-1}(\alpha)$ shifts by exactly $\delta$. Differentiating with respect to $\delta$ at
$\delta = 0$:
\[
1 = \frac{\mathrm{d}\tau}{\mathrm{d}\delta}\bigg|_{\delta=0}
= \sum_{\mathbf{x}_i \in \mathcal{B}_0} \frac{\partial \tau}{\partial f_\theta(\mathbf{x}_i)}
\]
Summing the $y_i = 0$ gradients therefore gives:
\begin{equation}
\sum_{\mathbf{x}_i \in \mathcal{B}_0}
\frac{\partial \mathcal{L}}{\partial f_\theta(\mathbf{x}_i)}
= \frac{\partial \hat{F}_1(\tau)}{\partial \tau} \cdot 1
= \frac{\partial \hat{F}_1(\tau)}{\partial \tau}
\label{eq:grad-balance-b0}
\end{equation}
\medskip\noindent\textit{Sum over $\mathcal{B}_1$.}
For $y_i = 1$, $\frac{\partial \mathcal{L}}{\partial f_\theta(\mathbf{x}_i)} = \frac{\partial \hat{F}_1(\tau)}{\partial f_\theta(\mathbf{x}_i)}$.
Shifting all positive scores by $\delta$ and applying translation invariance of $\hat{F}_1$:
$\hat{F}_1(\tau\,;\,\mathbf{s}+\delta\mathbf{1}) = \hat{F}_1(\tau-\delta\,;\,\mathbf{s})$.
Differentiating at $\delta = 0$:
\[
\sum_{\mathbf{x}_i \in \mathcal{B}_1}
\frac{\partial \hat{F}_1(\tau)}{\partial f_\theta(\mathbf{x}_i)}
= -\frac{\partial \hat{F}_1(\tau)}{\partial \tau}
\]
Combining with \eqref{eq:grad-balance-b0} gives \eqref{eq:grad-balance}.
\end{proof}
The translation-invariance assumption holds for all distribution families considered in this
work: for Gaussian MLE, a uniform shift in scores moves $\mu_k$ by the same amount while
leaving $\sigma_k$ unchanged, which translates $\hat{F}_k$; for KDE, each kernel term is
evaluated at $\tau - f_\theta(\mathbf{x}_j)$, so a uniform shift in the $f_\theta(\mathbf{x}_j)$
is equivalent to an equal shift in $\tau$. The condition is necessary: without it, a uniform
score shift need not produce a rigid translation of $\hat{F}_k$, so the shift argument in the
proof breaks down and the gradient sums need not be equal. A natural example where this fails
is a family that first maps scores through a nonlinear link function before fitting, such as
passing scores through a sigmoid into $[0,1]$ before fitting a Beta distribution. A uniform
additive shift of the raw scores then produces a non-uniform shift of the transformed inputs,
changing the shape of the fitted distribution rather than merely translating it, and the
balance property no longer holds.
\subsection{Gradient Computation and the Custom Backward Pass}
\label{sec:roll-backward}
% Because the distribution parameters are themselves functions of model scores
% (not fixed), the backward pass must differentiate through the distribution
% fitting step. Describe the custom autograd implementation: how gradients flow
% from the ROLL loss back through the distribution parameters to the model
% weights. Highlight where standard autograd would fail and what the manual
% backward pass does differently.
%------------------------------------------------
\section{Implementation Considerations} \section{Implementation Considerations}
\label{sec:roll-implementation} \label{sec:roll-implementation}
@@ -720,6 +801,18 @@ where $\tau = \hat{F}_0^{-1}(\alpha ; \mathcal{B}_0)$.
% NOTE - not silverman's rule, we do use scheduling, but we also use different % NOTE - not silverman's rule, we do use scheduling, but we also use different
% estimator - see impl. % estimator - see impl.
When computing KDE, kernel selection and bandwidth estimation affect the final result greatly. Large bandwidths
don't accurately track the probability distribution, while small kernels result in a very jagged CDF, which for us means very low gradient values unless unless a point is very close to the decision threshold.
Use of the Improved Sheather Jones method of kernel density estimation worked reliably well at creating very close-tracking, yet smooth CDFs.
\subsubsection{Bandwidth Scaling for KDE}
\label{sec:kde-bandwidth-scaling}
While the Improved Sheather Jones method worked very well for selecting an acceptable bandwidth, this wasn't necessarily wanted during training. Near the start of the training session, scores tended to be all low. This naturally made the selected bandwidth to be too low. This caused very low training performance near the start of a training session, which could result in non-convergence of the model even after significant training epochs elapsed.
The solution was to use a bandwidth scheduler. Starting with large bandwidths resulted in gradients that spread out more evenly across all scores, and less non-convergence runs occurred. The bandwidth scheduler artificially scales up the bandwidth at the beginning to speed up initial training, and then tapers back to restore the intended bandwidth in order to maximize resuslts.
% TODO: algorithm box — full training loop (forward → ROLL loss → custom backward → weight update) % TODO: algorithm box — full training loop (forward → ROLL loss → custom backward → weight update)