Implement the frozen F3 protocol, nested LOWO, posterior label banks, ablations, diagnostics, checkpoint validation and full-volume inference. Record the negative G-C result: improvement at 1/4 wells, coverage80 52.38% and coverage90 60.91%, with unchanged thresholds and historical P2 results. Add native Windows logging, the RTX 3060 environment lock, detached runs, and an audited dashboard-lock recovery that preserves frozen scientific code. Update report.html, the plan and agent guidance with completed P3 status. Archive thesis sources under code_thesis with identical Git blobs and record the original-output audit without committing large data or model artifacts. Validation: 129 tests passed, 13 skipped; CUDA end-to-end smoke passed; completion audit verified 1,320 checkpoint/prediction pairs, 28 registration bundles and all 649 interior volume inlines. Scripts 04 and 09 were not rerun. Co-authored-by: Codex <codex@openai.com>
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
"""Dilated CNN + 2-layer bidirectional GRU + 1×1 skip head.
|
||
|
||
Ported verbatim from `code_thesis/train_open_patch_v2.py` (class CNNGRU); the architecture is unchanged.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import torch
|
||
import torch.nn as nn
|
||
|
||
|
||
class CNNGRU(nn.Module):
|
||
def __init__(self, in_ch: int, d: int = 64, pdrop: float = 0.05):
|
||
super().__init__()
|
||
self.cnn = nn.Sequential(
|
||
nn.Conv1d(in_ch, d, kernel_size=5, padding=2, dilation=1), nn.ReLU(),
|
||
nn.Dropout(pdrop),
|
||
nn.Conv1d(d, d, kernel_size=5, padding=4, dilation=2), nn.ReLU(),
|
||
nn.Dropout(pdrop),
|
||
nn.Conv1d(d, d, kernel_size=5, padding=8, dilation=4), nn.ReLU(),
|
||
)
|
||
self.gru = nn.GRU(
|
||
input_size=d, hidden_size=d, num_layers=2,
|
||
batch_first=True, bidirectional=True, dropout=0.0,
|
||
)
|
||
self.head = nn.Conv1d(2 * d, 1, kernel_size=1)
|
||
self.head_skip = nn.Conv1d(in_ch, 1, kernel_size=1)
|
||
self.bias = nn.Parameter(torch.zeros(1))
|
||
|
||
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
||
# x: (B, C, L) -> (B, 1, L)
|
||
h = self.cnn(x)
|
||
h2, _ = self.gru(h.transpose(1, 2))
|
||
y_main = self.head(h2.transpose(1, 2))
|
||
y_skip = self.head_skip(x)
|
||
return y_main + y_skip + self.bias.view(1, 1, 1)
|