resnet_18
orchard.architectures.resnet_18
¶
ResNet-18 Multi-Resolution Architecture.
Adaptive ResNet-18 supporting 28x28, 32x32, 64x64, 128x128, and 224x224 resolutions with resolution-specific architectural modifications.
Resolution-Specific Adaptations:
28x28 / 32x32:
- 7x7 Conv1 → 3x3 Conv1 (stride 1 instead of 2)
- MaxPool removed (prevents excessive spatial loss)
- Weight morphing via bicubic interpolation
64x64 / 128x128 / 224x224:
- Standard ResNet-18 stem (7x7 Conv1, stride 2, MaxPool)
- Only channel adaptation for grayscale inputs
build_resnet_18(num_classes, in_channels, *, pretrained, resolution)
¶
Constructs ResNet-18 with resolution-aware architectural adaptation.
At 28x28/32x32, performs stem surgery to preserve spatial resolution. At 64x64, 128x128, and 224x224, uses the standard ResNet-18 architecture.
Workflow
- Load ImageNet pretrained ResNet-18 (if enabled)
- Apply resolution-specific stem adaptation
- Replace classification head with dataset-specific linear layer
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_classes
|
int
|
Number of dataset classes |
required |
in_channels
|
int
|
Input channels (1=Grayscale, 3=RGB) |
required |
pretrained
|
bool
|
Whether to load ImageNet pretrained weights |
required |
resolution
|
int
|
Input image resolution (28, 32, 64, 128, or 224) |
required |
Returns:
| Type | Description |
|---|---|
Module
|
Adapted ResNet-18 (device placement handled by factory). |