sage.architecture.network.mscnn1d_att_resnet2d_cbam
Filename : legacy.py Description : Short description of the file
Created on 2025-11-06 12:57:18
__author__ = Narenraju Nagarajan __copyright__ = Copyright 2025, ProjectName __license__ = MIT Licence __version__ = 0.0.1 __maintainer__ = Narenraju Nagarajan __affiliation__ = N/A __email__ = N/A __status__ = [‘inProgress’, ‘Archived’, ‘inUsage’, ‘Debugging’]
GitHub Repository: NULL
Documentation: NULL
Classes
Multi-scale CNN backend + ResNet CBAM frontend for GW detection. |
|
Multi-scale CNN frontend + ResNet CBAM backend for GW detection. |
|
Forward output of |
|
Heteroscedastic detection network + multi-detector consistency heads. |
Module Contents
- class MSCNN1D_2DResNetCBAM(frontend_filters=32, frontend_kernel=64, backend_resnet_size=50, norm_type='groupnorm', dropout=0.0)[source]
Bases:
torch.nn.ModuleMulti-scale CNN backend + ResNet CBAM frontend for GW detection.
- Parameters:
backend_filters – base filter size for ConvBlock backend
backend_kernel – base kernel size for ConvBlock backend
resnet_size – 18, 34, 50, 101, 152
norm_type (str) – ‘batchnorm’, ‘layernorm’, ‘instancenorm’
num_point_estimates – number of continuous parameters to predict
frontend_filters (int)
frontend_kernel (int)
backend_resnet_size (int)
dropout (float)
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- class MSCNN1D_2DResNetCBAM_Heteroscedastic(frontend_filters=32, frontend_kernel=64, backend_resnet_size=50, norm_type='groupnorm', dropout=0.0)[source]
Bases:
torch.nn.ModuleMulti-scale CNN frontend + ResNet CBAM backend for GW detection. Outputs:
Ranking statistic (BCE)
Point estimates (mean + log variance for heteroscedastic regression)
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- Parameters:
- forward(x)[source]
x: Tensor of shape (B, num_detectors=2, signal_length) :returns: (B, 1)
- point_estimates: (B, 2*num_pe)
Blocked format: [mu_0, mu_1, …, sraw_0, sraw_1, …] (all predicted means first, then all raw sigma params). The raw sigma params are mapped to a strictly-positive std via softplus inside BCEWithPEsigmaLoss (no exp(log_var) collapse). This matches the layout expected by BCEWithPEsigmaLoss and SageUncompiledValidation, which split at [:num_pe] / [num_pe:].
- Return type:
ranking_statistic
- class ConsistencyOutput[source]
Bases:
NamedTupleForward output of
MSCNN1D_2DResNetCBAM_Consistency.- ranking_stat: torch.Tensor[source]
- point_estimates: torch.Tensor[source]
- mu_tc: torch.Tensor[source]
- sigma_tc: torch.Tensor[source]
- mu_mc: torch.Tensor[source]
- sigma_mc: torch.Tensor[source]
- s_tc: torch.Tensor[source]
- s_mc: torch.Tensor[source]
- class MSCNN1D_2DResNetCBAM_Consistency(t_grid, frontend_filters=32, frontend_kernel=64, backend_resnet_size=50, norm_type='groupnorm', head_hidden=128, dropout=0.0)[source]
Bases:
torch.nn.ModuleHeteroscedastic detection network + multi-detector consistency heads.
Identical merged backbone (two frontends -> 2-D ResNet-CBAM -> ranking + heteroscedastic PE heads) to
MSCNN1D_2DResNetCBAM_Heteroscedastic, plus a sharedPerDetHeadapplied to each frontend output (pre-merge). The per-detectortc/mchirpestimates form an uncertainty-weighted consistency statistic(s_tc, s_mc); those, the per-detector sigmas and the attention entropies are concatenated into the ranking head input as a learned corroboration combiner (not a hard gate).- Parameters:
t_grid (torch.Tensor, shape
(L,)) – Physical time (seconds) of each multirate output sample, fromoutput_time_grid(). Adaptive-averaged to the frontend’s time length to give the per-stept_positionthetcsoft-argmax sums over.frontend_filters (int) – As in the heteroscedastic model.
frontend_kernel (int) – As in the heteroscedastic model.
backend_resnet_size (int) – As in the heteroscedastic model.
norm_type (str) – As in the heteroscedastic model.
head_hidden (int) – Hidden width of the per-detector head MLPs.
state (Initialize internal Module)
ScriptModule. (shared by both nn.Module and)
dropout (float)
- forward(x, return_embedding=False)[source]
Returns a
ConsistencyOutput. Whenreturn_embeddingis True, returns(ConsistencyOutput, embedding)instead, whereembeddingis the per-detector attention-pooled frontend feature, shape(B, D, C)– used by the hard-noise miner as its QD diversity descriptor. Default False keeps the standard output untouched.- Parameters:
return_embedding (bool)