module_7_html = """ Module 7: Deep Learning for Image Understanding

Module 7: Deep Learning for Image Understanding

1. Learning Objectives

2. Neural Networks Recap

A neural network consists of layers of interconnected nodes ("neurons"). Each neuron performs a weighted sum of inputs followed by a non-linear activation function like ReLU or Sigmoid.

output = activation(Wx + b)

3. Convolutional Neural Networks (CNNs)

4. Famous Architectures

5. PyTorch Implementation Example


import torch.nn as nn

class SimpleCNN(nn.Module):
    def __init__(self):
        super(SimpleCNN, self).__init__()
        self.conv1 = nn.Conv2d(1, 32, kernel_size=3)
        self.pool = nn.MaxPool2d(2, 2)
        self.fc1 = nn.Linear(32 * 13 * 13, 10)

    def forward(self, x):
        x = self.pool(nn.functional.relu(self.conv1(x)))
        x = x.view(-1, 32 * 13 * 13)
        x = self.fc1(x)
        return x

6. Training Loop


for epoch in range(epochs):
    for inputs, labels in dataloader:
        optimizer.zero_grad()
        outputs = model(inputs)
        loss = criterion(outputs, labels)
        loss.backward()
        optimizer.step()

7. Transfer Learning

Use a pre-trained model like ResNet and fine-tune it for your dataset. Benefits:

8. Assignment

Objective: Train a CNN from scratch and compare with transfer learning

Due: End of Week 7