Model Pipeline - Image generation basics
This pipeline shows how a simple neural network learns to generate small images from random noise. It starts with random input, trains a model to create images, and improves over time.
This pipeline shows how a simple neural network learns to generate small images from random noise. It starts with random input, trains a model to create images, and improves over time.
Loss
1.2 |************
0.8 |********
0.5 |*****
0.3 |***
+----------------
1 5 10 15 Epochs
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 1.2 | 0.10 | Model starts with random images, loss is high, accuracy low |
| 5 | 0.8 | 0.35 | Images start to show rough shapes, loss decreases |
| 10 | 0.5 | 0.60 | Generated images look clearer, accuracy improves |
| 15 | 0.3 | 0.80 | Images resemble real data well, loss low, accuracy high |
import torch
noise = torch.randn(8, 100)
generator = torch.nn.Sequential(
torch.nn.Linear(100, 256),
torch.nn.ReLU(),
torch.nn.Linear(256, 784),
torch.nn.Tanh()
)
fake_images = generator(noise)
import torch
class Generator(torch.nn.Module):
def __init__(self):
super().__init__()
self.fc = torch.nn.Linear(100, 784)
def forward(self, x):
x = self.fc(x)
x = torch.sigmoid(x)
return x
noise = torch.randn(16, 100)
gen = Generator()
output = gen(noise).reshape(16, 28, 28)
Pass the test and this pattern moves unknown