sage.architecture.backend.resnet2d_cbam

Filename : resnet2d_cbam.py Description : Short description of the file

Created on 2026-03-06 13:29:06

__author__ = Narenraju Nagarajan __copyright__ = Copyright 2026, Sage __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

ResNet

2D ResNet backbone with CBAM attention in every residual block.

Functions

resnet18_cbam([pretrained])

Constructs a ResNet-18 model.

resnet34_cbam([pretrained])

Constructs a ResNet-34 model.

resnet50_cbam([pretrained])

Constructs a ResNet-50 model.

resnet101_cbam([pretrained])

Constructs a ResNet-101 model.

resnet152_cbam([pretrained])

Constructs a ResNet-152 model.

Module Contents

class ResNet(block, layers, num_classes=512, in_channels=2, dropout=0.0)[source]

Bases: torch.nn.Module

2D ResNet backbone with CBAM attention in every residual block.

Adapted from the standard torchvision ResNet to: 1. Accept multi-channel gravitational-wave inputs (default in_channels=2

for H1/L1 detector pair).

  1. Insert ChannelAttention and SpatialAttention gates inside every BasicBlock and Bottleneck.

  2. Output a flat feature vector of size num_classes (default 512) via global average pooling + a linear projection.

The model is used as the backend of the Sage detection network, receiving 2D feature maps produced by the per-detector 1D CNN frontend.

Parameters:
  • block (type) – Residual block class — BasicBlock (ResNet-18/34) or Bottleneck (ResNet-50/101/152).

  • layers (list[int]) – Number of blocks per stage, e.g. [3, 4, 6, 3] for ResNet-50.

  • num_classes (int) – Output feature dimension (default 512).

  • in_channels (int) – Number of input channels (default 2 for dual-detector).

  • state (Initialize internal Module)

  • ScriptModule. (shared by both nn.Module and)

inplanes = 64[source]
conv1[source]
bn1[source]
relu[source]
maxpool[source]
layer1[source]
layer2[source]
layer3[source]
layer4[source]
avgpool[source]
fc[source]
forward(x)[source]
resnet18_cbam(pretrained=False, **kwargs)[source]

Constructs a ResNet-18 model.

Parameters:

pretrained (bool) – If True, returns a model pre-trained on ImageNet

resnet34_cbam(pretrained=False, **kwargs)[source]

Constructs a ResNet-34 model.

Parameters:

pretrained (bool) – If True, returns a model pre-trained on ImageNet

resnet50_cbam(pretrained=False, **kwargs)[source]

Constructs a ResNet-50 model.

Parameters:

pretrained (bool) – If True, returns a model pre-trained on ImageNet

resnet101_cbam(pretrained=False, **kwargs)[source]

Constructs a ResNet-101 model.

Parameters:

pretrained (bool) – If True, returns a model pre-trained on ImageNet

resnet152_cbam(pretrained=False, **kwargs)[source]

Constructs a ResNet-152 model.

Parameters:

pretrained (bool) – If True, returns a model pre-trained on ImageNet