Deep Learning Models: A collection of various deep learning architectures, models, & their implementations (PyTorch or TensorFlow) in Jupyter Notebooks.
- Author: Chizoba Obasi
- Github Repo: https://github.com/chizkidd/deep-learning-models
!pip install watermark
Collecting watermark Downloading watermark-2.6.0-py3-none-any.whl.metadata (15 kB) Requirement already satisfied: ipython>=6.0 in /usr/local/lib/python3.12/dist-packages (from watermark) (7.34.0) Requirement already satisfied: importlib-metadata>=1.4 in /usr/local/lib/python3.12/dist-packages (from watermark) (8.7.0) Requirement already satisfied: setuptools in /usr/local/lib/python3.12/dist-packages (from watermark) (75.2.0) Requirement already satisfied: zipp>=3.20 in /usr/local/lib/python3.12/dist-packages (from importlib-metadata>=1.4->watermark) (3.23.0) Collecting jedi>=0.16 (from ipython>=6.0->watermark) Downloading jedi-0.19.2-py2.py3-none-any.whl.metadata (22 kB) Requirement already satisfied: decorator in /usr/local/lib/python3.12/dist-packages (from ipython>=6.0->watermark) (4.4.2) Requirement already satisfied: pickleshare in /usr/local/lib/python3.12/dist-packages (from ipython>=6.0->watermark) (0.7.5) Requirement already satisfied: traitlets>=4.2 in /usr/local/lib/python3.12/dist-packages (from ipython>=6.0->watermark) (5.7.1) Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.12/dist-packages (from ipython>=6.0->watermark) (3.0.52) Requirement already satisfied: pygments in /usr/local/lib/python3.12/dist-packages (from ipython>=6.0->watermark) (2.19.2) Requirement already satisfied: backcall in /usr/local/lib/python3.12/dist-packages (from ipython>=6.0->watermark) (0.2.0) Requirement already satisfied: matplotlib-inline in /usr/local/lib/python3.12/dist-packages (from ipython>=6.0->watermark) (0.2.1) Requirement already satisfied: pexpect>4.3 in /usr/local/lib/python3.12/dist-packages (from ipython>=6.0->watermark) (4.9.0) Requirement already satisfied: parso<0.9.0,>=0.8.4 in /usr/local/lib/python3.12/dist-packages (from jedi>=0.16->ipython>=6.0->watermark) (0.8.5) Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.12/dist-packages (from pexpect>4.3->ipython>=6.0->watermark) (0.7.0) Requirement already satisfied: wcwidth in /usr/local/lib/python3.12/dist-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=6.0->watermark) (0.2.14) Downloading watermark-2.6.0-py3-none-any.whl (13 kB) Downloading jedi-0.19.2-py2.py3-none-any.whl (1.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 35.2 MB/s eta 0:00:00 Installing collected packages: jedi, watermark Successfully installed jedi-0.19.2 watermark-2.6.0
!pip install torchinfo
Collecting torchinfo Downloading torchinfo-1.8.0-py3-none-any.whl.metadata (21 kB) Downloading torchinfo-1.8.0-py3-none-any.whl (23 kB) Installing collected packages: torchinfo Successfully installed torchinfo-1.8.0
%load_ext watermark
# %reload_ext watermark
%watermark -a 'Chizoba Obasi' -v -p torch
Author: Chizoba Obasi Python implementation: CPython Python version : 3.12.12 IPython version : 7.34.0 torch: 2.9.0+cu126
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
from sklearn.model_selection import train_test_split
from torch.amp import GradScaler, autocast
from torchinfo import summary
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
%matplotlib inline
import pandas as pd
import numpy as np
import math
import time
import os
import random
if torch.cuda.is_available():
torch.backends.cudnn.deterministic = True
def set_all_seeds(seed):
os.environ["PL_GLOBAL_SEED"] = str(seed)
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# Check if GPU is available and set the device
if torch.cuda.is_available():
num_gpus = torch.cuda.device_count()
print("Num GPUs Available: ", num_gpus)
for i in range(num_gpus):
gpu_name = torch.cuda.get_device_name(i)
print(f"GPU {i}: {gpu_name}")
else:
print("No GPU available.")
Num GPUs Available: 1 GPU 0: Tesla T4
ResNet: Residual Blocks¶
- Single Residual Block: The fundamental innovation of a Residual Block is the "shortcut connection" (or skip connection). Instead of forcing the layers to learn the underlying mapping H(x), we let them learn the residual mapping F(x) = H(x) - x. The output becomes F(x) + x. This allows the gradient to flow through the shortcut during backpropagation, effectively solving the vanishing gradient problem and allowing for much deeper architectures.

- Various Usages of Activation in residual Block: This diagram illustrates the placement of Batch Normalization (BN) and ReLU activation relative to the convolutional layers. While the original ResNet (2015) used Post-activation (applying ReLU after the addition), subsequent research (He et al., 2016) introduced Pre-activation ResNet. In the pre-activation version, BN and ReLU are applied before the weight layers, which eases optimization and improves the regularization of the model.

Types of Residual Block: ResNet architectures use two primary building blocks depending on the depth of the network:
- Basic Block: Used in ResNet-$18$ and ResNet-$34$. It consists of two consecutive $3 \times 3$ convolutional layers.
- Bottleneck Block: Used in deeper versions like ResNet-$50$, $101$, and $152$. It uses a triplet of $1 \times 1$, $3 \times 3$, and $1 \times 1$ convolutions. The $1 \times 1$ layers are used to first reduce (bottleneck) and then restore dimensions, significantly reducing the number of parameters and computational cost while maintaining performance.
![]()
ResNet-152 Classifier on CIFAR-10¶

Network Architecture: The network in this notebook is an implementation of the ResNet-152 [1] architecture on the Cifar-10 dataset to train an image classifier.
| layer name | output size | 18-layer | 34-layer | 50-layer | 101-layer | 152-layer |
|---|---|---|---|---|---|---|
| conv1 | 112×112 | 7×7, 64, stride 2 | 7×7, 64, stride 2 | 7×7, 64, stride 2 | 7×7, 64, stride 2 | 7×7, 64, stride 2 |
| conv2_x | 56×56 | 3×3 max pool, stride 2 | 3×3 max pool, stride 2 | 3×3 max pool, stride 2 | 3×3 max pool, stride 2 | 3×3 max pool, stride 2 |
| $\begin{bmatrix} 3\times3, 64 \\ 3\times3, 64 \end{bmatrix} \times 2$ | $\begin{bmatrix} 3\times3, 64 \\ 3\times3, 64 \end{bmatrix} \times 3$ | $\begin{bmatrix} 1\times1, 64 \\ 3\times3, 64 \\ 1\times1, 256 \end{bmatrix} \times 3$ | $\begin{bmatrix} 1\times1, 64 \\ 3\times3, 64 \\ 1\times1, 256 \end{bmatrix} \times 3$ | $\begin{bmatrix} 1\times1, 64 \\ 3\times3, 64 \\ 1\times1, 256 \end{bmatrix} \times 3$ | ||
| conv3_x | 28×28 | $\begin{bmatrix} 3\times3, 128 \\ 3\times3, 128 \end{bmatrix} \times 2$ | $\begin{bmatrix} 3\times3, 128 \\ 3\times3, 128 \end{bmatrix} \times 4$ | $\begin{bmatrix} 1\times1, 128 \\ 3\times3, 128 \\ 1\times1, 512 \end{bmatrix} \times 4$ | $\begin{bmatrix} 1\times1, 128 \\ 3\times3, 128 \\ 1\times1, 512 \end{bmatrix} \times 4$ | $\begin{bmatrix} 1\times1, 128 \\ 3\times3, 128 \\ 1\times1, 512 \end{bmatrix} \times 8$ |
| conv4_x | 14×14 | $\begin{bmatrix} 3\times3, 256 \\ 3\times3, 256 \end{bmatrix} \times 2$ | $\begin{bmatrix} 3\times3, 256 \\ 3\times3, 256 \end{bmatrix} \times 6$ | $\begin{bmatrix} 1\times1, 256 \\ 3\times3, 256 \\ 1\times1, 1024 \end{bmatrix} \times 6$ | $\begin{bmatrix} 1\times1, 256 \\ 3\times3, 256 \\ 1\times1, 1024 \end{bmatrix} \times 23$ | $\begin{bmatrix} 1\times1, 256 \\ 3\times3, 256 \\ 1\times1, 1024 \end{bmatrix} \times 36$ |
| conv5_x | 7×7 | $\begin{bmatrix} 3\times3, 512 \\ 3\times3, 512 \end{bmatrix} \times 2$ | $\begin{bmatrix} 3\times3, 512 \\ 3\times3, 512 \end{bmatrix} \times 3$ | $\begin{bmatrix} 1\times1, 512 \\ 3\times3, 512 \\ 1\times1, 2048 \end{bmatrix} \times 3$ | $\begin{bmatrix} 1\times1, 512 \\ 3\times3, 512 \\ 1\times1, 2048 \end{bmatrix} \times 3$ | $\begin{bmatrix} 1\times1, 512 \\ 3\times3, 512 \\ 1\times1, 2048 \end{bmatrix} \times 3$ |
| 1×1 | avg pool, 1000-d fc, softmax | avg pool, 1000-d fc, softmax | avg pool, 1000-d fc, softmax | avg pool, 1000-d fc, softmax | avg pool, 1000-d fc, softmax | |
| FLOPs | 1.8 × 10⁹ | 3.6 × 10⁹ | 3.8 × 10⁹ | 7.6 × 10⁹ | 11.3 × 10⁹ |
Table adapted from ResNet paper
Key Notes on the Architecture:
- Building Blocks: The 18-layer and 34-layer networks use basic blocks (two 3×3 convs), while the deeper 50/101/152-layer networks use bottleneck blocks (1×1, 3×3, and 1×1 convs).
- Downsampling: Downsampling is performed by
conv3_1,conv4_1, andconv5_1with a stride of 2. - Global Average Pooling: This is used at the end of the convolutional layers to reduce the spatial dimensions to 1×1 before the fully connected layer.
The following figure illustrates residual blocks with skip connections such that the input passed via the shortcut matches the dimensions of the main path's output, which allows the network to learn identity functions.

The ResNet-18/34 architecture actually uses residual blocks with skip connections such that the input passed via the shortcut matches is resized to dimensions of the main path's output. Such a residual block is illustrated below:

The ResNet-152 uses a bottleneck as shown below:

Improvements over LeNet, AlexNet, VGG:
- Skip Connections: Unlike VGG and AlexNet, ResNet uses "identity mapping" which solves the vanishing gradient problem.
- Global Average Pooling: Instead of a huge Flatten + Dense layer (like in AlexNet), we use
avg_pool2d. This significantly reduces parameter count and prevents overfitting. - Batch Normalization: ResNet relies heavily on BN after every convolution to stabilize training at a higher learning rate.
REFERENCES:
He, K., Zhang, X., Ren, S., & Sun, J. "Deep residual learning for image recognition." Proceedings of the IEEE conference on computer vision and pattern recognition. 2016. (770-77).
Johnson, J. (2022, February 2). Lecture 8: CNN Architectures [PowerPoint Slides]. University of Michigan EECS 498/598: Deep Learning for Computer Vision. pp 77-109. https://web.eecs.umich.edu/~justincj/slides/eecs498/WI2022/598_WI2022_lecture08.pdf
Mahdid, Y. (2024.). deep-learning-model-explained: ResNet [Source code]. GitHub. https://github.com/yacineMahdid/deep-learning-model-explained/tree/main/resnet
##########################
### SETTINGS
##########################
# Hyperparameters
RANDOM_SEED = 123
BATCH_SIZE = 32 #128 #256
LEARNING_RATE = 0.001
NUM_EPOCHS = 20
INPUT_SIZE = 32 # CIFAR-10 is 32x32
NUM_CLASSES = 10
# Set device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(device)
cuda
# Mean and Std Dev for CIFAR-10 (3 channels)
CIFAR_MEAN = (0.4914, 0.4822, 0.4465)
CIFAR_STD = (0.2471, 0.2435, 0.2616)
train_transforms = transforms.Compose([
transforms.RandomRotation(15),
transforms.RandomCrop(32, padding=4, padding_mode='reflect'),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize(CIFAR_MEAN, CIFAR_STD)
])
test_transforms = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize(CIFAR_MEAN, CIFAR_STD)
])
# Load Datasets
train_dataset = datasets.CIFAR10(root='./data', train=True, download=True, transform=train_transforms)
test_dataset = datasets.CIFAR10(root='./data', train=False, download=True, transform=test_transforms)
# Split training set into training and validation sets
train_size = int(0.9 * len(train_dataset))
val_size = len(train_dataset) - train_size
train_subset, val_subset = torch.utils.data.random_split(train_dataset, [train_size, val_size])
# Create DataLoaders
train_loader = DataLoader(train_subset, batch_size=BATCH_SIZE, shuffle=True, num_workers=2, pin_memory=True)
val_loader = DataLoader(val_subset, batch_size=BATCH_SIZE, shuffle=False, num_workers=2, pin_memory=True)
test_loader = DataLoader(test_dataset, batch_size=BATCH_SIZE, shuffle=False, num_workers=2, pin_memory=True)
100%|██████████| 170M/170M [00:05<00:00, 30.1MB/s]
2. Model Creation¶
Notes:
- This implementation uses a $3 \times 3$ initial convolution (instead of $7 \times 7$) and removes the initial MaxPool to preserve the spatial resolution of the small $32 \times 32$ images.
class BasicBlock(nn.Module):
expansion = 1
def __init__(self, in_planes, planes, stride=1):
super(BasicBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
self.bn1 = nn.BatchNorm2d(planes)
self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=1, padding=1, bias=False)
self.bn2 = nn.BatchNorm2d(planes)
self.relu = nn.ReLU(inplace=True)
self.shortcut = nn.Sequential()
if stride != 1 or in_planes != self.expansion*planes:
self.shortcut = nn.Sequential(
nn.Conv2d(in_planes, self.expansion*planes, kernel_size=1, stride=stride, bias=False),
nn.BatchNorm2d(self.expansion*planes)
)
def forward(self, x):
residual = self.shortcut(x)
out = self.relu(self.bn1(self.conv1(x))) # conv->batchnorm->relu
out = self.bn2(self.conv2(out)) # conv->batchnorm
out += residual # skip connection
out = torch.relu(out) # relu
return out
class Bottleneck(nn.Module):
expansion = 4 # The output of the block is 4x the width of the bottleneck
def __init__(self, in_planes, planes, stride=1):
super(Bottleneck, self).__init__()
# 1x1 Convolution to reduce dimensions
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=1, bias=False)
self.bn1 = nn.BatchNorm2d(planes)
# 3x3 Convolution for spatial processing
self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
self.bn2 = nn.BatchNorm2d(planes)
# 1x1 Convolution to expand dimensions (planes * 4)
self.conv3 = nn.Conv2d(planes, self.expansion * planes, kernel_size=1, bias=False)
self.bn3 = nn.BatchNorm2d(self.expansion * planes)
self.shortcut = nn.Sequential()
# Shortcut needs to match dimensions (if stride != 1 or channels change)
if stride != 1 or in_planes != self.expansion * planes:
self.shortcut = nn.Sequential(
nn.Conv2d(in_planes, self.expansion * planes, kernel_size=1, stride=stride, bias=False),
nn.BatchNorm2d(self.expansion * planes)
)
def forward(self, x):
residual = self.shortcut(x)
out = torch.relu(self.bn1(self.conv1(x))) # conv->batchnorm->relu
out = torch.relu(self.bn2(self.conv2(out))) # conv->batchnorm->relu
out = self.bn3(self.conv3(out)) # conv->batchnorm
out += residual # skip connection
out = torch.relu(out) # relu
return out
class ResNet(nn.Module):
def __init__(self, block, num_blocks, num_classes=10):
super(ResNet, self).__init__()
self.in_planes = 64
self.conv1 = nn.Conv2d(3, 64, kernel_size=3, stride=1, padding=1, bias=False)
self.bn1 = nn.BatchNorm2d(64)
self.relu = nn.ReLU(inplace=True)
self.layer1 = self._make_layer(block, 64, num_blocks[0], stride=1)
self.layer2 = self._make_layer(block, 128, num_blocks[1], stride=2)
self.layer3 = self._make_layer(block, 256, num_blocks[2], stride=2)
self.layer4 = self._make_layer(block, 512, num_blocks[3], stride=2)
self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
self.linear = nn.Linear(512*block.expansion, num_classes)
def _make_layer(self, block, planes, num_blocks, stride):
strides = [stride] + [1]*(num_blocks-1)
layers = []
for s in strides:
layers.append(block(self.in_planes, planes, s))
self.in_planes = planes * block.expansion
return nn.Sequential(*layers)
def forward(self, x):
out = torch.relu(self.bn1(self.conv1(x)))
out = self.layer1(out)
out = self.layer2(out)
out = self.layer3(out)
out = self.layer4(out)
out = self.avgpool(out)
out = torch.flatten(out, 1)
out = self.linear(out)
return out
def ResNet152():
return ResNet(Bottleneck, [3, 8, 36, 3])
def test_model_dims():
# Create a dummy batch: 2 images, 3 channels, 32x32 size
x = torch.randn(2, 3, 32, 32).to(device)
# Initialize model
net = ResNet152().to(device)
# Forward pass
y = net(x)
print(f"Input Shape: {x.shape}")
print(f"Output Shape: {y.shape}") # Should be [2, 10]
if y.shape == (2, 10):
print("✅ Sanity Check Passed: Dimensions are correct for CIFAR-10!")
else:
print("❌ Sanity Check Failed: Check your stride or pooling layers.")
test_model_dims()
Input Shape: torch.Size([2, 3, 32, 32]) Output Shape: torch.Size([2, 10]) ✅ Sanity Check Passed: Dimensions are correct for CIFAR-10!
set_all_seeds(RANDOM_SEED)
model = ResNet152().to(device)
# Model parameter details
summary(model,
input_size=(BATCH_SIZE, 3, INPUT_SIZE, INPUT_SIZE),
# verbose=1,
col_names=["input_size", "output_size", "num_params", "kernel_size", "mult_adds"]
)
===================================================================================================================================================================== Layer (type:depth-idx) Input Shape Output Shape Param # Kernel Shape Mult-Adds ===================================================================================================================================================================== ResNet [32, 3, 32, 32] [32, 10] -- -- -- ├─Conv2d: 1-1 [32, 3, 32, 32] [32, 64, 32, 32] 1,728 [3, 3] 56,623,104 ├─BatchNorm2d: 1-2 [32, 64, 32, 32] [32, 64, 32, 32] 128 -- 4,096 ├─Sequential: 1-3 [32, 64, 32, 32] [32, 256, 32, 32] -- -- -- │ └─Bottleneck: 2-1 [32, 64, 32, 32] [32, 256, 32, 32] -- -- -- │ │ └─Sequential: 3-1 [32, 64, 32, 32] [32, 256, 32, 32] 16,896 -- 536,887,296 │ │ └─Conv2d: 3-2 [32, 64, 32, 32] [32, 64, 32, 32] 4,096 [1, 1] 134,217,728 │ │ └─BatchNorm2d: 3-3 [32, 64, 32, 32] [32, 64, 32, 32] 128 -- 4,096 │ │ └─Conv2d: 3-4 [32, 64, 32, 32] [32, 64, 32, 32] 36,864 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-5 [32, 64, 32, 32] [32, 64, 32, 32] 128 -- 4,096 │ │ └─Conv2d: 3-6 [32, 64, 32, 32] [32, 256, 32, 32] 16,384 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-7 [32, 256, 32, 32] [32, 256, 32, 32] 512 -- 16,384 │ └─Bottleneck: 2-2 [32, 256, 32, 32] [32, 256, 32, 32] -- -- -- │ │ └─Sequential: 3-8 [32, 256, 32, 32] [32, 256, 32, 32] -- -- -- │ │ └─Conv2d: 3-9 [32, 256, 32, 32] [32, 64, 32, 32] 16,384 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-10 [32, 64, 32, 32] [32, 64, 32, 32] 128 -- 4,096 │ │ └─Conv2d: 3-11 [32, 64, 32, 32] [32, 64, 32, 32] 36,864 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-12 [32, 64, 32, 32] [32, 64, 32, 32] 128 -- 4,096 │ │ └─Conv2d: 3-13 [32, 64, 32, 32] [32, 256, 32, 32] 16,384 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-14 [32, 256, 32, 32] [32, 256, 32, 32] 512 -- 16,384 │ └─Bottleneck: 2-3 [32, 256, 32, 32] [32, 256, 32, 32] -- -- -- │ │ └─Sequential: 3-15 [32, 256, 32, 32] [32, 256, 32, 32] -- -- -- │ │ └─Conv2d: 3-16 [32, 256, 32, 32] [32, 64, 32, 32] 16,384 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-17 [32, 64, 32, 32] [32, 64, 32, 32] 128 -- 4,096 │ │ └─Conv2d: 3-18 [32, 64, 32, 32] [32, 64, 32, 32] 36,864 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-19 [32, 64, 32, 32] [32, 64, 32, 32] 128 -- 4,096 │ │ └─Conv2d: 3-20 [32, 64, 32, 32] [32, 256, 32, 32] 16,384 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-21 [32, 256, 32, 32] [32, 256, 32, 32] 512 -- 16,384 ├─Sequential: 1-4 [32, 256, 32, 32] [32, 512, 16, 16] -- -- -- │ └─Bottleneck: 2-4 [32, 256, 32, 32] [32, 512, 16, 16] -- -- -- │ │ └─Sequential: 3-22 [32, 256, 32, 32] [32, 512, 16, 16] 132,096 -- 1,073,774,592 │ │ └─Conv2d: 3-23 [32, 256, 32, 32] [32, 128, 32, 32] 32,768 [1, 1] 1,073,741,824 │ │ └─BatchNorm2d: 3-24 [32, 128, 32, 32] [32, 128, 32, 32] 256 -- 8,192 │ │ └─Conv2d: 3-25 [32, 128, 32, 32] [32, 128, 16, 16] 147,456 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-26 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-27 [32, 128, 16, 16] [32, 512, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-28 [32, 512, 16, 16] [32, 512, 16, 16] 1,024 -- 32,768 │ └─Bottleneck: 2-5 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Sequential: 3-29 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Conv2d: 3-30 [32, 512, 16, 16] [32, 128, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-31 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-32 [32, 128, 16, 16] [32, 128, 16, 16] 147,456 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-33 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-34 [32, 128, 16, 16] [32, 512, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-35 [32, 512, 16, 16] [32, 512, 16, 16] 1,024 -- 32,768 │ └─Bottleneck: 2-6 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Sequential: 3-36 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Conv2d: 3-37 [32, 512, 16, 16] [32, 128, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-38 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-39 [32, 128, 16, 16] [32, 128, 16, 16] 147,456 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-40 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-41 [32, 128, 16, 16] [32, 512, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-42 [32, 512, 16, 16] [32, 512, 16, 16] 1,024 -- 32,768 │ └─Bottleneck: 2-7 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Sequential: 3-43 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Conv2d: 3-44 [32, 512, 16, 16] [32, 128, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-45 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-46 [32, 128, 16, 16] [32, 128, 16, 16] 147,456 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-47 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-48 [32, 128, 16, 16] [32, 512, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-49 [32, 512, 16, 16] [32, 512, 16, 16] 1,024 -- 32,768 │ └─Bottleneck: 2-8 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Sequential: 3-50 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Conv2d: 3-51 [32, 512, 16, 16] [32, 128, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-52 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-53 [32, 128, 16, 16] [32, 128, 16, 16] 147,456 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-54 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-55 [32, 128, 16, 16] [32, 512, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-56 [32, 512, 16, 16] [32, 512, 16, 16] 1,024 -- 32,768 │ └─Bottleneck: 2-9 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Sequential: 3-57 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Conv2d: 3-58 [32, 512, 16, 16] [32, 128, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-59 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-60 [32, 128, 16, 16] [32, 128, 16, 16] 147,456 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-61 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-62 [32, 128, 16, 16] [32, 512, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-63 [32, 512, 16, 16] [32, 512, 16, 16] 1,024 -- 32,768 │ └─Bottleneck: 2-10 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Sequential: 3-64 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Conv2d: 3-65 [32, 512, 16, 16] [32, 128, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-66 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-67 [32, 128, 16, 16] [32, 128, 16, 16] 147,456 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-68 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-69 [32, 128, 16, 16] [32, 512, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-70 [32, 512, 16, 16] [32, 512, 16, 16] 1,024 -- 32,768 │ └─Bottleneck: 2-11 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Sequential: 3-71 [32, 512, 16, 16] [32, 512, 16, 16] -- -- -- │ │ └─Conv2d: 3-72 [32, 512, 16, 16] [32, 128, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-73 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-74 [32, 128, 16, 16] [32, 128, 16, 16] 147,456 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-75 [32, 128, 16, 16] [32, 128, 16, 16] 256 -- 8,192 │ │ └─Conv2d: 3-76 [32, 128, 16, 16] [32, 512, 16, 16] 65,536 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-77 [32, 512, 16, 16] [32, 512, 16, 16] 1,024 -- 32,768 ├─Sequential: 1-5 [32, 512, 16, 16] [32, 1024, 8, 8] -- -- -- │ └─Bottleneck: 2-12 [32, 512, 16, 16] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-78 [32, 512, 16, 16] [32, 1024, 8, 8] 526,336 -- 1,073,807,360 │ │ └─Conv2d: 3-79 [32, 512, 16, 16] [32, 256, 16, 16] 131,072 [1, 1] 1,073,741,824 │ │ └─BatchNorm2d: 3-80 [32, 256, 16, 16] [32, 256, 16, 16] 512 -- 16,384 │ │ └─Conv2d: 3-81 [32, 256, 16, 16] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-82 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-83 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-84 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-13 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-85 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-86 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-87 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-88 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-89 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-90 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-91 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-14 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-92 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-93 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-94 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-95 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-96 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-97 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-98 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-15 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-99 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-100 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-101 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-102 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-103 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-104 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-105 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-16 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-106 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-107 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-108 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-109 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-110 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-111 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-112 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-17 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-113 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-114 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-115 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-116 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-117 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-118 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-119 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-18 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-120 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-121 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-122 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-123 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-124 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-125 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-126 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-19 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-127 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-128 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-129 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-130 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-131 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-132 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-133 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-20 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-134 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-135 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-136 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-137 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-138 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-139 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-140 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-21 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-141 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-142 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-143 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-144 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-145 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-146 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-147 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-22 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-148 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-149 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-150 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-151 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-152 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-153 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-154 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-23 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-155 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-156 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-157 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-158 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-159 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-160 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-161 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-24 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-162 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-163 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-164 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-165 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-166 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-167 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-168 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-25 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-169 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-170 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-171 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-172 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-173 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-174 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-175 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-26 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-176 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-177 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-178 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-179 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-180 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-181 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-182 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-27 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-183 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-184 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-185 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-186 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-187 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-188 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-189 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-28 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-190 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-191 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-192 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-193 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-194 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-195 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-196 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-29 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-197 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-198 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-199 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-200 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-201 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-202 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-203 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-30 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-204 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-205 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-206 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-207 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-208 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-209 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-210 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-31 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-211 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-212 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-213 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-214 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-215 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-216 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-217 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-32 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-218 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-219 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-220 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-221 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-222 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-223 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-224 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-33 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-225 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-226 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-227 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-228 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-229 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-230 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-231 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-34 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-232 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-233 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-234 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-235 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-236 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-237 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-238 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-35 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-239 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-240 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-241 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-242 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-243 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-244 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-245 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-36 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-246 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-247 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-248 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-249 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-250 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-251 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-252 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-37 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-253 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-254 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-255 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-256 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-257 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-258 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-259 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-38 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-260 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-261 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-262 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-263 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-264 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-265 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-266 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-39 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-267 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-268 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-269 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-270 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-271 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-272 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-273 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-40 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-274 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-275 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-276 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-277 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-278 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-279 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-280 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-41 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-281 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-282 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-283 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-284 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-285 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-286 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-287 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-42 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-288 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-289 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-290 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-291 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-292 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-293 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-294 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-43 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-295 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-296 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-297 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-298 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-299 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-300 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-301 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-44 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-302 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-303 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-304 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-305 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-306 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-307 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-308 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-45 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-309 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-310 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-311 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-312 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-313 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-314 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-315 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-46 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-316 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-317 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-318 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-319 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-320 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-321 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-322 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 │ └─Bottleneck: 2-47 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Sequential: 3-323 [32, 1024, 8, 8] [32, 1024, 8, 8] -- -- -- │ │ └─Conv2d: 3-324 [32, 1024, 8, 8] [32, 256, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-325 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-326 [32, 256, 8, 8] [32, 256, 8, 8] 589,824 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-327 [32, 256, 8, 8] [32, 256, 8, 8] 512 -- 16,384 │ │ └─Conv2d: 3-328 [32, 256, 8, 8] [32, 1024, 8, 8] 262,144 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-329 [32, 1024, 8, 8] [32, 1024, 8, 8] 2,048 -- 65,536 ├─Sequential: 1-6 [32, 1024, 8, 8] [32, 2048, 4, 4] -- -- -- │ └─Bottleneck: 2-48 [32, 1024, 8, 8] [32, 2048, 4, 4] -- -- -- │ │ └─Sequential: 3-330 [32, 1024, 8, 8] [32, 2048, 4, 4] 2,101,248 -- 1,073,872,896 │ │ └─Conv2d: 3-331 [32, 1024, 8, 8] [32, 512, 8, 8] 524,288 [1, 1] 1,073,741,824 │ │ └─BatchNorm2d: 3-332 [32, 512, 8, 8] [32, 512, 8, 8] 1,024 -- 32,768 │ │ └─Conv2d: 3-333 [32, 512, 8, 8] [32, 512, 4, 4] 2,359,296 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-334 [32, 512, 4, 4] [32, 512, 4, 4] 1,024 -- 32,768 │ │ └─Conv2d: 3-335 [32, 512, 4, 4] [32, 2048, 4, 4] 1,048,576 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-336 [32, 2048, 4, 4] [32, 2048, 4, 4] 4,096 -- 131,072 │ └─Bottleneck: 2-49 [32, 2048, 4, 4] [32, 2048, 4, 4] -- -- -- │ │ └─Sequential: 3-337 [32, 2048, 4, 4] [32, 2048, 4, 4] -- -- -- │ │ └─Conv2d: 3-338 [32, 2048, 4, 4] [32, 512, 4, 4] 1,048,576 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-339 [32, 512, 4, 4] [32, 512, 4, 4] 1,024 -- 32,768 │ │ └─Conv2d: 3-340 [32, 512, 4, 4] [32, 512, 4, 4] 2,359,296 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-341 [32, 512, 4, 4] [32, 512, 4, 4] 1,024 -- 32,768 │ │ └─Conv2d: 3-342 [32, 512, 4, 4] [32, 2048, 4, 4] 1,048,576 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-343 [32, 2048, 4, 4] [32, 2048, 4, 4] 4,096 -- 131,072 │ └─Bottleneck: 2-50 [32, 2048, 4, 4] [32, 2048, 4, 4] -- -- -- │ │ └─Sequential: 3-344 [32, 2048, 4, 4] [32, 2048, 4, 4] -- -- -- │ │ └─Conv2d: 3-345 [32, 2048, 4, 4] [32, 512, 4, 4] 1,048,576 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-346 [32, 512, 4, 4] [32, 512, 4, 4] 1,024 -- 32,768 │ │ └─Conv2d: 3-347 [32, 512, 4, 4] [32, 512, 4, 4] 2,359,296 [3, 3] 1,207,959,552 │ │ └─BatchNorm2d: 3-348 [32, 512, 4, 4] [32, 512, 4, 4] 1,024 -- 32,768 │ │ └─Conv2d: 3-349 [32, 512, 4, 4] [32, 2048, 4, 4] 1,048,576 [1, 1] 536,870,912 │ │ └─BatchNorm2d: 3-350 [32, 2048, 4, 4] [32, 2048, 4, 4] 4,096 -- 131,072 ├─AdaptiveAvgPool2d: 1-7 [32, 2048, 4, 4] [32, 2048, 1, 1] -- -- -- ├─Linear: 1-8 [32, 2048] [32, 10] 20,490 -- 655,680 ===================================================================================================================================================================== Total params: 58,156,618 Trainable params: 58,156,618 Non-trainable params: 0 Total mult-adds (Units.GIGABYTES): 119.11 ===================================================================================================================================================================== Input size (MB): 0.39 Forward/backward pass size (MB): 3670.02 Params size (MB): 232.63 Estimated Total Size (MB): 3903.04 =====================================================================================================================================================================
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=LEARNING_RATE)
# optimizer = optim.SGD(model.parameters(), lr=0.1, momentum=0.9, weight_decay=5e-4)
scheduler = optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=200)
scaler = GradScaler('cuda')
# Function to calculate accuracy
def calculate_accuracy(loader):
model.eval()
correct = 0
total = 0
with torch.no_grad():
for inputs, labels in loader:
inputs, labels = inputs.to(device), labels.to(device)
with autocast('cuda'):
outputs = model(inputs)
_, predicted = torch.max(outputs.data, 1)
total += labels.size(0)
correct += (predicted == labels).sum().item()
return 100 * correct / total
# Training Loop
start_time = time.time()
history = {'train_loss': [], 'val_loss': [], 'train_acc': [], 'val_acc': [], 'lrs': []}
print(f"Starting training on {device}...")
for epoch in range(NUM_EPOCHS):
model.train()
running_loss, correct_train, total_train = 0.0, 0, 0
for i, (inputs, labels) in enumerate(train_loader):
inputs, labels = inputs.to(device), labels.to(device)
optimizer.zero_grad()
with autocast('cuda'):
outputs = model(inputs)
loss = criterion(outputs, labels)
scaler.scale(loss).backward()
scaler.step(optimizer)
scaler.update()
running_loss += loss.item() * inputs.size(0)
_, predicted = torch.max(outputs, 1)
total_train += labels.size(0)
correct_train += (predicted == labels).sum().item()
train_loss = running_loss / len(train_subset)
train_acc = 100 * correct_train / total_train
# Calculate validation loss and accuracy
model.eval()
val_loss, correct_val, total_val = 0.0, 0, 0
with torch.no_grad():
for inputs, labels in val_loader:
inputs, labels = inputs.to(device), labels.to(device)
with autocast('cuda'):
outputs = model(inputs)
loss = criterion(outputs, labels)
val_loss += loss.item() * inputs.size(0)
_, predicted = torch.max(outputs, 1)
total_val += labels.size(0)
correct_val += (predicted == labels).sum().item()
val_loss /= len(val_subset)
val_acc = 100 * correct_val / total_val
scheduler.step()
current_lr = optimizer.param_groups[0]['lr']
history['train_loss'].append(train_loss)
history['val_loss'].append(val_loss)
history['train_acc'].append(train_acc)
history['val_acc'].append(val_acc)
history['lrs'].append(current_lr)
print(f'Epoch {epoch + 1}/{NUM_EPOCHS} | '
f'Train Loss: {train_loss:.5f}, '
f'Train Accuracy: {train_acc:.2f}% | '
f'Val Loss: {val_loss:.5f}, '
f'Val Accuracy: {val_acc:.2f}% | '
f'Learning Rate: {current_lr:.8f}')
print('\nTotal Training Time: %.2f min' % ((time.time() - start_time)/60))
# Final Evaluation
test_accuracy = calculate_accuracy(test_loader)
print(f'\nTest Accuracy: {test_accuracy:.2f}%')
Starting training on cuda... Epoch 1/20 | Train Loss: 1.84623, Train Accuracy: 31.86% | Val Loss: 1.55480, Val Accuracy: 43.42% | Learning Rate: 0.00099994 Epoch 2/20 | Train Loss: 1.59522, Train Accuracy: 41.52% | Val Loss: 1.44275, Val Accuracy: 49.08% | Learning Rate: 0.00099975 Epoch 3/20 | Train Loss: 1.35439, Train Accuracy: 51.04% | Val Loss: 1.18136, Val Accuracy: 57.48% | Learning Rate: 0.00099944 Epoch 4/20 | Train Loss: 1.19063, Train Accuracy: 57.28% | Val Loss: 1.63407, Val Accuracy: 59.34% | Learning Rate: 0.00099901 Epoch 5/20 | Train Loss: 1.07432, Train Accuracy: 61.74% | Val Loss: 1.00716, Val Accuracy: 64.24% | Learning Rate: 0.00099846 Epoch 6/20 | Train Loss: 0.97463, Train Accuracy: 65.63% | Val Loss: 1.40932, Val Accuracy: 61.34% | Learning Rate: 0.00099778 Epoch 7/20 | Train Loss: 0.90570, Train Accuracy: 68.40% | Val Loss: nan, Val Accuracy: 58.78% | Learning Rate: 0.00099698 Epoch 8/20 | Train Loss: 0.83696, Train Accuracy: 70.65% | Val Loss: 0.78038, Val Accuracy: 74.42% | Learning Rate: 0.00099606 Epoch 9/20 | Train Loss: 0.74255, Train Accuracy: 74.08% | Val Loss: 0.77777, Val Accuracy: 75.82% | Learning Rate: 0.00099501 Epoch 10/20 | Train Loss: 0.68038, Train Accuracy: 76.24% | Val Loss: 0.61438, Val Accuracy: 79.62% | Learning Rate: 0.00099384 Epoch 11/20 | Train Loss: 0.63970, Train Accuracy: 77.84% | Val Loss: 0.60335, Val Accuracy: 79.22% | Learning Rate: 0.00099255 Epoch 12/20 | Train Loss: 0.59815, Train Accuracy: 79.20% | Val Loss: 0.63011, Val Accuracy: 79.90% | Learning Rate: 0.00099114 Epoch 13/20 | Train Loss: 0.55188, Train Accuracy: 81.02% | Val Loss: 0.87705, Val Accuracy: 80.10% | Learning Rate: 0.00098961 Epoch 14/20 | Train Loss: 0.53200, Train Accuracy: 81.74% | Val Loss: 0.66467, Val Accuracy: 81.30% | Learning Rate: 0.00098796 Epoch 15/20 | Train Loss: 0.50274, Train Accuracy: 82.46% | Val Loss: 0.53108, Val Accuracy: 82.38% | Learning Rate: 0.00098618 Epoch 16/20 | Train Loss: 0.48995, Train Accuracy: 83.13% | Val Loss: 0.50167, Val Accuracy: 83.90% | Learning Rate: 0.00098429 Epoch 17/20 | Train Loss: 0.45228, Train Accuracy: 84.30% | Val Loss: 0.53744, Val Accuracy: 84.14% | Learning Rate: 0.00098228 Epoch 18/20 | Train Loss: 0.43135, Train Accuracy: 84.86% | Val Loss: 0.49054, Val Accuracy: 84.02% | Learning Rate: 0.00098015 Epoch 19/20 | Train Loss: 0.41357, Train Accuracy: 85.72% | Val Loss: nan, Val Accuracy: 83.54% | Learning Rate: 0.00097790 Epoch 20/20 | Train Loss: 0.39946, Train Accuracy: 86.09% | Val Loss: 0.48577, Val Accuracy: 85.04% | Learning Rate: 0.00097553 Total Training Time: 67.48 min Test Accuracy: 87.59%
def plot_history(history):
"""
Plots the training and validation loss, accuracy, and learning rate
from a PyTorch history dictionary.
Args:
history (dict): Dictionary containing training metrics.
Expected keys: 'train_loss', 'val_loss', 'train_acc', 'val_acc', 'lrs'.
"""
epochs = range(len(history['train_loss']))
plt.figure(figsize=(18, 5))
# Plot 1: Loss
plt.subplot(1, 3, 1)
plt.plot(epochs, history['train_loss'], label='Training Loss')
plt.plot(epochs, history['val_loss'], label='Validation Loss')
plt.title('Loss')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
# plt.grid(True)
# Plot 2: Accuracy
plt.subplot(1, 3, 2)
plt.plot(epochs, history['train_acc'], label='Training Accuracy')
plt.plot(epochs, history['val_acc'], label='Validation Accuracy')
plt.title('Accuracy')
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.legend()
# plt.grid(True)
# Plot 3: Learning Rate
plt.subplot(1, 3, 3)
plt.plot(epochs, history['lrs'], label='Learning Rate', color='orange')
plt.title('Learning Rate')
plt.xlabel('Epochs')
plt.ylabel('Learning Rate')
plt.legend()
# plt.grid(True)
plt.tight_layout()
plt.show()
# plt.savefig()
plot_history(history)
%watermark -iv
matplotlib : 3.10.0 numpy : 2.0.2 pandas : 2.2.2 sklearn : 1.6.1 torch : 2.9.0+cu126 torchinfo : 1.8.0 torchvision: 0.24.0+cu126