[home]   [coding projects]   [research projects]


Convolutional Neural Networks

Depth, architecture, and optimizer experiments on CIFAR-10.

[full source]

This project moves the same experimental style to image classification on CIFAR-10. A custom convolutional network is compared across depth, against ResNet-18, and under SGD versus Adam. Training augmentation is deliberately kept separate from validation/test preprocessing.

1. Data pipeline

The code computes channel means and standard deviations from the selected training subset, then uses random horizontal flips, rotations, and padded random crops only for training. Validation and test data receive normalization but no augmentation.

2. The configurable CNN

Christopher_Housholder_HW3.py
class SimpleCNN(nn.Module):
    def __init__(self, depth=2):
        super().__init__()

        self.module1 = ConvBlock(
            3, 32, depth, stride=1
        )
        self.module2 = ConvBlock(
            32, 64, depth, stride=2
        )
        self.module3 = ConvBlock(
            64, 128, depth, stride=2
        )

        self.global_pool = nn.AdaptiveAvgPool2d((1, 1))
        self.fc = nn.Linear(128, 10)

    def forward(self, x):
        x = self.module1(x)
        x = self.module2(x)
        x = self.module3(x)
        x = self.global_pool(x)
        x = x.view(x.size(0), -1)
        return self.fc(x)

Each convolutional block is a configurable number of Conv2d → BatchNorm → ReLU layers. Downsampling happens by stride rather than an explicit pooling layer, and the classifier uses global average pooling before the final ten-way linear layer.

3. What the experiments ask

Experiment A changes the number of convolutional layers per module. Experiment B compares the deeper custom CNN with a randomly initialized ResNet-18. Experiment C keeps the architecture fixed and changes the optimizer. In the accompanying report, depth improves accuracy with some added instability, ResNet mainly improves early optimization smoothness, and Adam converges faster within the limited training budget.

Validation accuracy for shallow and deeper custom CNNs.
Validation accuracy for shallow and deeper custom CNNs.
Training/validation loss under the depth comparison.
Training/validation loss under the depth comparison.
Custom CNN versus ResNet-18 validation accuracy.
Custom CNN versus ResNet-18 validation accuracy.
Custom CNN versus ResNet-18 loss.
Custom CNN versus ResNet-18 loss.
SGD versus Adam validation accuracy.
SGD versus Adam validation accuracy.
SGD versus Adam training loss.
SGD versus Adam training loss.

These pages are selective technical manuals: enough source to expose the mechanism, not a mirror of the entire repository.
Last updated: September 14, 2026.