Files
ML-Porosity/paper/sections/05_method.tex
lamlvh 381b5ffb06 Add P6 benchmark code, locked protocol_bench, T2 study
- ml_porosity/benchmark/ runner, scripts 32-35, scripts/run_bench.sh;
  misspec= option in synth_d2 (default path reproduces P2r bit for bit).
- configs/protocol_bench.{yaml,sha256,lock.json} locked 29/10 14:39 UTC
  (sha256 aa763f0a...), configs/d2_synth_bench.yaml.
- T2 mechanism declaration and results; operations/p6_supervisor.py.
- Docs, report and paper edits of 29/10.

outputs/ stays out of git; the repository folder is synced as a whole to
the new server. Main S1 runs are still training at this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 01:33:18 +00:00

158 lines
16 KiB
TeX

\section{Registration-marginalized learning}
\label{sec:method}
This section describes the tie posterior and registration-marginalized learning (RML), a loss that contains the compared methods as special cases. We use RML to define the methods on a common footing, not as a proposed method expected to win (contribution C3). RML has two stages. First, a posterior over the time--depth warp of each training well is computed from anchors and, optionally, from the seismic. No network is involved. Second, a network is trained on a bank of labels drawn from this posterior. At prediction time no warp is needed: the network maps seismic to a property trace on the seismic time axis.
\subsection{Warp prior and anchors}
\label{sec:method:prior}
For well $w$ with depth logs $\phi_w(z)$, $\mathrm{DT}_w(z)$ and $\rho_w(z)$, the time--depth map is
\begin{equation}
t_w(z; b_w, g_w) = t_{w,\mathrm{ref}} + b_w + 2\int_{z_{\mathrm{ref}}}^{z} \mathrm{DT}_w(u)\, e^{g_w(u)}\dd u .
\label{eq:warp}
\end{equation}
The log-slowness correction $g_w$ describes sonic--seismic drift from dispersion, tool effects or washouts. Because $e^{g} > 0$, the map is monotone by construction. $b_w \sim \N(0, \sigma_b^2)$ is a bulk offset. The prior on $g_w$ is a Gaussian process with constant mean $m_g$ and a Mat\'ern-3/2 kernel with scale $\sigma_g$ and length $\ell$. The hyperparameters $(m_g, \sigma_g, \ell)$ are fitted by type-II maximum likelihood on the anchors of the training wells only. $\sigma_a$ and $\sigma_b$ are fixed. Anchors are observed as $t_{wk} = t_w(z_{wk}) + \varepsilon_{wk}$ with $\varepsilon_{wk} \sim \N(0, \sigma_a^2)$. On F3, \eqref{eq:warp} has an important consequence: the same sonic log produces both the label and the time axis, so label and registration are coupled.
Fitted to the F3 anchors, the prior has $m_g = 0.014$, $\sigma_g = 0.10$ and $\ell = 71$\,ms. The fitted bulk spread is $\sigma_b = 19$\,ms. In leave-one-anchor-out tests, 87\% of held-out anchors lie inside the 90\% predictive interval. The synthetic benchmark draws its true warps from this fitted prior (Section~\ref{sec:data:d2}). Type-II maximum likelihood for $\sigma_a$ on F3 gives 0.4\,ms. This value is not reliable, because it treats the markers as exact: they are picks on the same seismic. We therefore use the empirical spread $\sigma_a = 7$\,ms (Section~\ref{sec:data:f3}). On F3, $\sigma_a$ is not identifiable from the data at hand.
\subsection{Physical tie likelihood}
\label{sec:method:tie}
For a training well with seismic trace $\mathbf s_w$ at the well location,
\begin{equation}
p(\mathbf s_w \mid g_w, b_w, \psi) = \N\big(\mathbf s_w;\ \alpha_w \mathbf W_\psi\, \mathbf r_w(b_w, g_w),\ \sigma_n^2 \mathbf I\big),
\end{equation}
where $\mathbf r_w$ is the reflectivity computed from acoustic impedance $\rho_w/\mathrm{DT}_w$ along the warp and blocked to 4\,ms, and $\mathbf W_\psi$ convolves with a 128\,ms statistical wavelet rotated by a constant phase $\psi$. The amplitude $\alpha_w \ge 0$ and the noise level $\sigma_n$ are profiled out, which gives $\log p = -\tfrac n2 \log \mathrm{RSS}$ over the extended window. The residuals are autocorrelated, so this likelihood is overconfident. We temper it by $\gamma = 1/\kappa$, where $\kappa$ is the variance inflation implied by the residual autocorrelation at the best anchor-only sample. The phase $\psi$ is chosen on a $15^\circ$ grid by marginal likelihood on the training wells. Test wells never enter this step.
\subsection{Two tie posteriors}
\label{sec:method:posterior}
\paragraph{Anchor posterior with importance weights (Experiment~1).}
We draw $S = 64$ warps per well from the anchor-conditioned posterior. The proposal is a Laplace (Gauss--Newton) approximation, refined by elliptical slice sampling \citep{murray2010ess}. Physical weights $\pi_s \propto p(\mathbf s_w\mid u^{(s)})^{\gamma}$ use the largest $\gamma$ that keeps the effective sample size at least $S/4$.
\paragraph{Sequential Monte Carlo posterior (Experiment~2).}
Importance weights over 64 anchor-conditioned samples cannot move mass to warps that the anchor posterior rarely proposes. In development runs the weighted posterior did not contract to the true warp (Section~\ref{sec:exp:diag}). The second posterior therefore uses tempered sequential Monte Carlo. We introduced it only after the first pre-registered comparison had failed, so it is a deviation from the original protocol, and we report it as one (Section~\ref{sec:exp:diag}). It starts from $P = 1024$ anchor-posterior samples and targets $p(u\mid \text{anchors})\, p(\mathbf s_w\mid u, \psi)^{\gamma}$. The tempering exponent rises from 0 to $\gamma$ in adaptive steps that keep the effective sample size at least $P/2$. Each step uses systematic resampling followed by eight elliptical slice moves. Before the trial we registered a stability criterion: the 95th percentile over $t$ of the difference between mean warps of independent runs must not exceed 0.5\,ms. $P = 1024$ meets it at $c = 1$ on development data. At $c = 2$ the posterior is multimodal and the mean warp is unstable under every configuration we tried. We summarize posterior width by $\sigpost = w_{90}/3.29$, where $w_{90}$ is the 90\% interval width of $\tau(t)$ averaged over the main window and the training wells. No labels are used to compute it.
\subsection{Labels for each warp}
\label{sec:method:labels}
For each warp sample,
\begin{equation}
y_w^{(s)}(t_i) = (\aaf\phi_w)\big(z_w^{(s)}(t_i)\big),
\end{equation}
where $z_w^{(s)}$ is the inverse of $t_w(\cdot\,; u^{(s)})$, which exists because the warp is monotone, and $\aaf$ is an anti-alias filter applied before sampling at 4\,ms. Samples whose warp does not cover the main window receive zero weight. Every method in this paper, including the point-tie baselines and the oracle, builds labels with the same operator. Methods differ only in the warps they use.
\subsection{Training objective}
\label{sec:method:rml}
The network outputs a mean $\mu_\theta$ and a standard deviation $\sigma_\theta$ for every sample. For a window of $n$ samples and a bank of $S$ labels with weights $\pi_s > 0$, $\sum_s \pi_s = 1$, let
\begin{equation}
\ell_s = \sum_{i=1}^{n} \log\N\big(y_{s,i};\, \mu_i, \sigma_i^2\big), \qquad
\RML_\lambda = -\frac{1}{\lambda n}\log\sum_{s=1}^{S}\pi_s\, e^{\lambda \ell_s}, \qquad
\RML_\infty = -\frac1n\max_s \ell_s .
\label{eq:rml}
\end{equation}
The training loss is the mean of $\RML_\lambda$ over windows and wells.
\paragraph{Choice of $\lambda$.}
With $\lambda = 1$, differences between bank members are $O(n)$ and the log-sum-exp puts almost all weight on one member. Residuals are also autocorrelated, so a window holds less information than $n$ independent observations. If two members differ by $\Delta = \sum_i d_i$, and $d_i$ is a product of two zero-mean Gaussian processes with common autocorrelation $\rho$, then $\Var\Delta \approx n \Var(d)\,\tau_c$ with $\tau_c = 1 + 2\sum_{k\ge1}\rho(k)^2$. Setting $\lambda = 1/\tau_c$ gives $\lambda\Delta$ the variance of a log-likelihood difference over $n/\tau_c$ independent observations. This is the simplest magnitude adjustment of a composite likelihood \citep{pauli2011composite,ribatet2012composite}. Residuals are not available before training, so we estimate $\rho$ from the pooled autocorrelation of the high-passed training labels, truncated at the first non-positive lag. This gives $\tau_c \approx 2.7$ samples and $\lambda \approx 0.37$, nearly constant across the grid. The choice is a heuristic. We fixed it before the experiments and make no claim about it.
\paragraph{Special cases.}
The loss \eqref{eq:rml} contains the common alternatives. All five statements are exact and are checked numerically in the code's unit tests. Proofs are in Appendix~\ref{app:proofs}.
\begin{lemma}[Point tie]
\label{lem:s1}
If $S = 1$, or all bank members coincide, then $\RML_\lambda = -\ell/n$, the Gaussian negative log-likelihood, for every $\lambda$.
\end{lemma}
\begin{lemma}[Between hard-min and mixture mean]
\label{lem:sandwich}
Let $M(\lambda) = \lambda^{-1}\log \E_\pi e^{\lambda\ell}$. Then $\RML_\lambda = -M(\lambda)/n$ is non-increasing in $\lambda$, with
\begin{equation}
-\frac1n\max_s\ell_s \le \RML_\lambda \le -\frac1n\sum_s\pi_s\ell_s ,
\end{equation}
and it tends to the right-hand side as $\lambda \to 0$ and to $\RML_\infty$ as $\lambda \to \infty$. For uniform $\pi$, $0 \le \RML_\lambda - \RML_\infty \le \log S/(\lambda n)$.
\end{lemma}
As $\lambda \to 0$, the optimal mean is the regression of the $\pi$-weighted mean label on $X$, and the optimal variance adds the spread of the bank. Whether this blurs the predictor depends on how the bank relates to the true warp. If the members scatter around a point tie whose error satisfies (A1), the mean label is blurred further. If the bank is the calibrated posterior, the population optimum is that of the true warp (Proposition~\ref{prop:bank}).
\begin{lemma}[Gradient]
\label{lem:grad}
$\nabla_\theta \RML_\lambda = -\frac1n\sum_s r_s \nabla_\theta \ell_s$ with responsibilities $r = \operatorname{softmax}(\log\pi + \lambda\ell)$.
\end{lemma}
Each gradient step is therefore a generalized M-step whose weights are computed at the current $\theta$.
\begin{lemma}[Shift-tolerant losses]
\label{lem:shift}
With a bank of the point-tie label shifted by every integer lag in $\pm K$ samples and uniform $\pi$, $\RML_\infty$ is the hard-min shift loss with learned variance, and $\RML_{1/\tau_c}$ is its soft-min version.
\end{lemma}
\begin{lemma}[Soft-DTW]
\label{lem:sdtw}
Let $D_{ij} = -\log\N(y_j; \mu_i, \sigma_i^2)$, let $\mathcal P$ be the set of monotone alignment paths from $(0,0)$ to $(n-1,n-1)$ within a Sakoe--Chiba band, and let $\langle A, D\rangle_w$ be the path cost with symmetric step weights (diagonal steps counted twice; \citealp{sakoe1978dp}). For soft-DTW with these steps \citep{cuturi2017softdtw},
\begin{equation}
\frac{\mathrm{sDTW}_\gamma(D)}{2n} = \RML_{\lambda = 2/\gamma}\Big[\text{bank} = \mathcal P,\ \pi \text{ uniform},\ \ell_A = -\tfrac12\langle A, D\rangle_w\Big] - \frac{\gamma}{2n}\log|\mathcal P| .
\end{equation}
\end{lemma}
The last term does not depend on $\theta$. On the diagonal path, $\ell_A$ equals the Gaussian log-likelihood of the window. Soft-DTW is therefore RML over every monotone alignment in the band, with a uniform prior, no anchors and no physics, at $\lambda = 2/\gamma$; with $\gamma = 0.1$ this is $\lambda = 20$, much closer to the hard minimum than $\lambda \approx 0.37$. Symmetric steps give every path the same total weight $2n$. With standard steps, longer paths visit more cells and, since the negative log-likelihood can be negative, would be preferred. DILATE \citep{leguen2019dilate} adds a temporal-distortion term $\langle A^\star, \Omega\rangle$ with $A^\star = \nabla_D \mathrm{sDTW}_\gamma$ and $\Omega_{ij} = ((i-j)/n)^2$. Its gradient is a Hessian--vector product, which we compute by forward-mode differentiation of the backward pass \citep{mensch2018diffdp}. Our version differs from the original in two ways: the cost is the Gaussian negative log-likelihood, and the steps are symmetric.
\subsection{Network and training}
\label{sec:method:train}
All learned methods share one backbone and differ only in their labels and loss. The input is a $3\times3$ trace patch around the well (nine channels), z-scored per channel within each well. Three dilated 1-D convolutions (kernel 5, dilations 1, 2 and 4, 64 channels) feed a two-layer bidirectional GRU. A $1\times1$ head with a $1\times1$ skip connection outputs $\mu$ and $\sigma$ (softplus, $\sigma \ge 10^{-3}$). Dropout is 0.05. We train with Adam (learning rate $5\times10^{-3}$, gradient clipping at 5) on full batches of all training wells. Losses are computed on 64-sample windows starting at samples $0, 2, \dots, 62$ of the 126-sample main window. Labels are standardized by the mean and standard deviation of the anti-aliased log over the training wells. These statistics do not depend on the tie. The number of iterations is selected separately for each method from $\{125, 250, 500, 1000, 2000\}$ by total RMSE on the development realizations; on F3 it is selected by inner validation (Appendix~\ref{sec:exp:f3}). Every method has the same candidate set, and band metrics are not used for selection. Ensembles average five seeds (on F3, three inner models $\times$ five seeds), with $\mu = \overline{\mu_s}$ and $\sigma^2 = \overline{\sigma_s^2} + \Var_s \mu_s$.
\subsection{Compared methods}
\label{sec:method:baselines}
Table~\ref{tab:methods} lists the methods. In the language of Lemmas~\ref{lem:s1}--\ref{lem:sdtw}, the B3 family is RML with $S = 1$ at different point ties. B4 is RML with anchor-free banks, and M1, M2 and \mRML{} are RML with anchor-conditioned banks.
\begin{table}[t]
\centering
\caption{Compared methods. All learned methods use the backbone of Section~\ref{sec:method:train}. Bank: labels entering \eqref{eq:rml}.}
\label{tab:methods}
\small
\begin{tabular}{lp{0.5\linewidth}l}
\toprule
ID & Labels / bank & Loss \\
\midrule
\multicolumn{3}{l}{\emph{Field baselines (F3 only)}} \\
B0a & depth--time trend fitted on training wells (no seismic) & -- \\
B0b & ridge, random forest or gradient boosting on seismic attributes and TWT & -- \\
B1 & model-based impedance inversion with a well-interpolated low-frequency model, then linear $\phi$--impedance & -- \\
B2 & backbone with a composite loss$^{\dagger}$ & composite \\
\midrule
\multicolumn{3}{l}{\emph{Point ties ($S = 1$)}} \\
B3a & sonic integration from one shallow anchor & NLL \\
B3b & marker-calibrated sonic through the anchors & NLL \\
B3c & B3b plus local shifts from synthetic--seismic correlation & NLL \\
B3c-R & B3c with the SMC-estimated wavelet phase & NLL \\
B3d & weighted mean warp of the Experiment~1 anchor posterior & NLL \\
\mPM & mean warp of the SMC posterior & NLL \\
Oracle & true warp (synthetic only; a ceiling, not a competitor) & NLL \\
\midrule
\multicolumn{3}{l}{\emph{Anchor-free alignment losses (labels B3b)}} \\
B4a & B3b shifted by $\pm 8$ samples, uniform $\pi$ & $\RML_\infty$ \\
B4b & as B4a & $\RML_{1/\tau_c}$ \\
B4c & all monotone alignments in a $\pm8$ band & soft-DTW, $\gamma = 0.1$ \\
B4d & as B4c & DILATE, $\alpha = 0.5$ \\
\midrule
\multicolumn{3}{l}{\emph{Anchor-conditioned banks}} \\
M1 & 64 anchor-posterior warps, uniform $\pi$ & $\RML_{1/\tau_c}$ \\
M2 & as M1, tempered physical weights & $\RML_{1/\tau_c}$ \\
\mRML & 64 SMC particles, uniform $\pi$ & $\RML_{1/\tau_c}$ \\
\midrule
B5 & five-seed ensemble of B3b & NLL \\
\bottomrule
\end{tabular}
\smallskip
\footnotesize $^{\dagger}$Labels as B3b; deterministic output. Loss: Huber regression loss $+\,0.60$ correlation $+\,0.05$ first-difference $+\,0.10$ standardized-shape $+\,0.10$ variance-matching $+\,0.20$ best-shift MSE (minimum over shifts of $\pm 8$ samples).
\end{table}
\subsection{Metrics}
\label{sec:method:metrics}
Accuracy is reported in porosity units (p.u., porosity $\times 100$). We split every trace into a low band ($|f| < f_c$) and a seismic band ($|f| \ge f_c$, $f_c = 6$\,Hz). The split uses a zero-phase fourth-order Butterworth filter. On F3, energy below 5\,Hz is 0.2--0.5\% of the total. The primary metrics are RMSE and Pearson correlation in the seismic band (band RMSE, band PCC): registration errors act there, while the low band is dominated by the trend. We also report total RMSE and PCC and the band standard-deviation ratio. Calibration is described by the coverage of central intervals at 50, 80, 90 and 95\%, the calibration error (mean absolute deviation of coverage from nominal over these levels), the Gaussian negative log-likelihood and the CRPS. Warp accuracy (synthetic only) is the RMSE of $\tau(t)$ against the true warp over the main window, together with 90\% coverage. Statistics are computed per test well and then macro-averaged. Intervals are 95\% bootstrap intervals over realizations (2000 resamples). On F3 the time samples within a well are not independent and there are only four wells. Field results are therefore descriptive, and we compute no per-sample $p$-values.