Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- .gitignore +106 -0
- Gan.ipynb +0 -0
- Generative Adversarial Networks (GANs).md +576 -0
- README.md +163 -0
- data/MNIST/raw/t10k-images-idx3-ubyte +3 -0
- data/MNIST/raw/t10k-images-idx3-ubyte.gz +3 -0
- data/MNIST/raw/t10k-labels-idx1-ubyte +0 -0
- data/MNIST/raw/t10k-labels-idx1-ubyte.gz +3 -0
- data/MNIST/raw/train-images-idx3-ubyte +3 -0
- data/MNIST/raw/train-images-idx3-ubyte.gz +3 -0
- data/MNIST/raw/train-labels-idx1-ubyte +0 -0
- data/MNIST/raw/train-labels-idx1-ubyte.gz +3 -0
- gan_training.log +291 -0
- gan_training_lite.log +0 -0
- generator_lite.pth +3 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
data/MNIST/raw/t10k-images-idx3-ubyte filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
data/MNIST/raw/train-images-idx3-ubyte filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# C extensions
|
| 7 |
+
*.so
|
| 8 |
+
|
| 9 |
+
# Distribution / packaging
|
| 10 |
+
.Python
|
| 11 |
+
build/
|
| 12 |
+
develop-eggs/
|
| 13 |
+
dist/
|
| 14 |
+
downloads/
|
| 15 |
+
eggs/
|
| 16 |
+
.eggs/
|
| 17 |
+
lib/
|
| 18 |
+
lib64/
|
| 19 |
+
parts/
|
| 20 |
+
sdist/
|
| 21 |
+
var/
|
| 22 |
+
wheels/
|
| 23 |
+
*.egg-info/
|
| 24 |
+
.installed.cfg
|
| 25 |
+
*.egg
|
| 26 |
+
MANIFEST
|
| 27 |
+
|
| 28 |
+
# PyInstaller
|
| 29 |
+
*.manifest
|
| 30 |
+
*.spec
|
| 31 |
+
|
| 32 |
+
# Installer logs
|
| 33 |
+
pip-log.txt
|
| 34 |
+
pip-delete-this-directory.txt
|
| 35 |
+
|
| 36 |
+
# Unit test / coverage reports
|
| 37 |
+
htmlcov/
|
| 38 |
+
.tox/
|
| 39 |
+
.coverage
|
| 40 |
+
.coverage.*
|
| 41 |
+
.cache
|
| 42 |
+
nosetests.xml
|
| 43 |
+
coverage.xml
|
| 44 |
+
*.cover
|
| 45 |
+
.hypothesis/
|
| 46 |
+
.pytest_cache/
|
| 47 |
+
|
| 48 |
+
# Jupyter Notebook
|
| 49 |
+
.ipynb_checkpoints
|
| 50 |
+
|
| 51 |
+
# pyenv
|
| 52 |
+
.python-version
|
| 53 |
+
|
| 54 |
+
# celery beat schedule file
|
| 55 |
+
celerybeat-schedule
|
| 56 |
+
|
| 57 |
+
# SageMath parsed files
|
| 58 |
+
*.sage.py
|
| 59 |
+
|
| 60 |
+
# Environments
|
| 61 |
+
.env
|
| 62 |
+
.venv
|
| 63 |
+
env/
|
| 64 |
+
venv/
|
| 65 |
+
ENV/
|
| 66 |
+
env.bak/
|
| 67 |
+
venv.bak/
|
| 68 |
+
|
| 69 |
+
# Spyder project settings
|
| 70 |
+
.spyderproject
|
| 71 |
+
.spyproject
|
| 72 |
+
|
| 73 |
+
# Rope project settings
|
| 74 |
+
.ropeproject
|
| 75 |
+
|
| 76 |
+
# mkdocs documentation
|
| 77 |
+
/site
|
| 78 |
+
|
| 79 |
+
# mypy
|
| 80 |
+
.mypy_cache/
|
| 81 |
+
.dmypy.json
|
| 82 |
+
dmypy.json
|
| 83 |
+
|
| 84 |
+
# IDE
|
| 85 |
+
.vscode/
|
| 86 |
+
.idea/
|
| 87 |
+
*.swp
|
| 88 |
+
*.swo
|
| 89 |
+
*~
|
| 90 |
+
|
| 91 |
+
# OS
|
| 92 |
+
.DS_Store
|
| 93 |
+
.DS_Store?
|
| 94 |
+
._*
|
| 95 |
+
.Spotlight-V100
|
| 96 |
+
.Trashes
|
| 97 |
+
ehthumbs.db
|
| 98 |
+
Thumbs.db
|
| 99 |
+
|
| 100 |
+
# Generated images
|
| 101 |
+
generated_samples_*.png
|
| 102 |
+
training_losses.png
|
| 103 |
+
|
| 104 |
+
# Temporary files
|
| 105 |
+
*.tmp
|
| 106 |
+
*.temp
|
Gan.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
Generative Adversarial Networks (GANs).md
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Let’s dive into a comprehensive learning journey on **Generative Adversarial Networks (GANs)**, following your structured prompt. I’ll provide a clear, concise, and thorough exploration of GANs, covering mathematical foundations, real-world examples, hands-on implementation, performance analysis, use cases, and resources for deeper learning.
|
| 2 |
+
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
## 🔬 Phase 1: Mathematical Foundations (30 minutes)
|
| 6 |
+
|
| 7 |
+
### Core Mathematical Concepts
|
| 8 |
+
|
| 9 |
+
#### 1. Mathematical Definition
|
| 10 |
+
**What are GANs mathematically?**
|
| 11 |
+
- GANs consist of two neural networks: a **Generator (G)** and a **Discriminator (D)**, trained simultaneously in a competitive setting.
|
| 12 |
+
- The **Generator** takes random noise \( z \sim p_z(z) \) (typically from a normal or uniform distribution) and generates fake data \( G(z) \).
|
| 13 |
+
- The **Discriminator** evaluates whether data is real (from the true data distribution \( p_{\text{data}}(x) \)) or fake (from \( G(z) \)).
|
| 14 |
+
- The objective is a minimax game where the Generator tries to "fool" the Discriminator, and the Discriminator tries to correctly classify real vs. fake data.
|
| 15 |
+
|
| 16 |
+
**Key Formula:**
|
| 17 |
+
The GAN objective function, as introduced by Goodfellow et al. (2014), is:
|
| 18 |
+
\[
|
| 19 |
+
\min_G \max_D V(D, G) = \mathbb{E}_{x \sim p_{\text{data}}(x)}[\log D(x)] + \mathbb{E}_{z \sim p_z(z)}[\log (1 - D(G(z)))]
|
| 20 |
+
\]
|
| 21 |
+
- \( D(x) \): Discriminator’s probability that \( x \) is real.
|
| 22 |
+
- \( G(z) \): Generator’s output given noise \( z \).
|
| 23 |
+
- The Discriminator maximizes the probability of correctly classifying real and fake samples, while the Generator minimizes the probability that the Discriminator correctly identifies its outputs as fake.
|
| 24 |
+
|
| 25 |
+
**Input/Output Relationships:**
|
| 26 |
+
- **Input to Generator**: Random noise vector \( z \) (e.g., 100-dimensional vector from \( \mathcal{N}(0,1) \)).
|
| 27 |
+
- **Output of Generator**: Synthetic data sample (e.g., an image, audio, or text).
|
| 28 |
+
- **Input to Discriminator**: Real data \( x \sim p_{\text{data}} \) or fake data \( G(z) \).
|
| 29 |
+
- **Output of Discriminator**: Scalar probability (0 to 1) indicating whether the input is real (close to 1) or fake (close to 0).
|
| 30 |
+
|
| 31 |
+
#### 2. Core Algorithms and Calculations
|
| 32 |
+
**Step-by-Step Procedure:**
|
| 33 |
+
1. **Sample Noise**: Draw random noise \( z \sim p_z(z) \) (e.g., Gaussian or uniform distribution).
|
| 34 |
+
2. **Generate Fake Data**: Pass \( z \) through the Generator to produce \( G(z) \).
|
| 35 |
+
3. **Sample Real Data**: Draw real data \( x \sim p_{\text{data}}(x) \) from the dataset.
|
| 36 |
+
4. **Train Discriminator**:
|
| 37 |
+
- Compute loss for real data: \( \log D(x) \).
|
| 38 |
+
- Compute loss for fake data: \( \log (1 - D(G(z))) \).
|
| 39 |
+
- Update Discriminator weights to maximize \( V(D, G) \).
|
| 40 |
+
5. **Train Generator**:
|
| 41 |
+
- Compute loss: \( \log (1 - D(G(z))) \) (or use a non-saturating loss like \( -\log D(G(z)) \)).
|
| 42 |
+
- Update Generator weights to minimize the Discriminator’s ability to detect fake data.
|
| 43 |
+
6. **Iterate**: Alternate between training D and G until convergence (or until the Generator produces realistic data).
|
| 44 |
+
|
| 45 |
+
**Background Calculations:**
|
| 46 |
+
- Both networks are trained using backpropagation with gradient-based optimizers (e.g., Adam).
|
| 47 |
+
- The Discriminator’s loss is the sum of binary cross-entropy losses for real and fake samples.
|
| 48 |
+
- The Generator’s loss depends on the Discriminator’s output for fake samples.
|
| 49 |
+
|
| 50 |
+
**Computational Complexity:**
|
| 51 |
+
- **Forward Pass**: Depends on the architecture of G and D (e.g., convolutional neural networks for images). Complexity is \( O(n) \), where \( n \) is the number of parameters.
|
| 52 |
+
- **Training**: Requires multiple forward/backward passes per iteration. Training GANs is computationally expensive due to the adversarial nature and need for balance between G and D.
|
| 53 |
+
- **Challenges**: Mode collapse (Generator produces limited variety) and vanishing gradients can slow convergence.
|
| 54 |
+
|
| 55 |
+
#### 3. Key Mathematical Properties
|
| 56 |
+
- **Equilibrium**: In theory, GANs converge to a Nash equilibrium where \( p_g(x) = p_{\text{data}}(x) \), and the Discriminator outputs \( D(x) = 0.5 \) for all inputs (can’t distinguish real from fake).
|
| 57 |
+
- **Assumptions**:
|
| 58 |
+
- The Generator and Discriminator have sufficient capacity (enough parameters).
|
| 59 |
+
- The training data distribution \( p_{\text{data}} \) is well-defined.
|
| 60 |
+
- The optimization process is stable (in practice, this is challenging).
|
| 61 |
+
- **Constraints**:
|
| 62 |
+
- GANs require careful balancing of G and D training to avoid one overpowering the other.
|
| 63 |
+
- Sensitive to hyperparameters (learning rate, network architecture).
|
| 64 |
+
- **Related Concepts**:
|
| 65 |
+
- GANs are related to game theory (minimax optimization).
|
| 66 |
+
- Connect to density estimation, as the Generator implicitly learns \( p_{\text{data}} \).
|
| 67 |
+
- Share similarities with variational autoencoders (VAEs) for generative modeling.
|
| 68 |
+
|
| 69 |
+
#### 4. Mathematical Intuition
|
| 70 |
+
- **Why It Works**: The adversarial setup mimics a competition where the Generator improves by trying to "trick" an increasingly better Discriminator, pushing \( p_g \rightarrow p_{\text{data}} \).
|
| 71 |
+
- **Geometric Interpretation**: The Generator maps a low-dimensional noise space to a high-dimensional data manifold, learning to approximate the true data distribution.
|
| 72 |
+
- **Statistical Interpretation**: The Discriminator estimates the divergence between \( p_g \) and \( p_{\text{data}} \), often related to Jensen-Shannon divergence.
|
| 73 |
+
- **AI/ML Connection**: GANs leverage deep learning (neural networks) and optimization (gradient descent) to learn complex data distributions without explicit density estimation.
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## 💡 Phase 2: Real-World Examples (20 minutes)
|
| 78 |
+
|
| 79 |
+
### Practical Applications
|
| 80 |
+
|
| 81 |
+
#### 1. Industry Applications
|
| 82 |
+
- **Image Generation**:
|
| 83 |
+
- **Company**: NVIDIA uses GANs in tools like **StyleGAN** for high-quality image synthesis (e.g., realistic faces, art). Their GauGAN tool creates photorealistic landscapes from sketches.
|
| 84 |
+
- **Product**: Adobe’s Photoshop uses GAN-based features for image enhancement and content-aware fill.
|
| 85 |
+
- **Success Story**: DeepArt.io uses GANs to transform photos into artworks mimicking famous artists’ styles.
|
| 86 |
+
- **Video Games**: Unity and Epic Games use GANs to generate textures, environments, or character designs.
|
| 87 |
+
- **Fashion**: Companies like Stitch Fix use GANs to design clothing patterns or generate virtual try-ons.
|
| 88 |
+
|
| 89 |
+
#### 2. Research Applications
|
| 90 |
+
- **Recent Papers**:
|
| 91 |
+
- “Progressive Growing of GANs” (Karras et al., 2018): Improved high-resolution image generation.
|
| 92 |
+
- “BigGAN” (Brock et al., 2018): Scaled GANs for better quality and diversity.
|
| 93 |
+
- “CycleGAN” (Zhu et al., 2017): Unpaired image-to-image translation (e.g., horse to zebra).
|
| 94 |
+
- **Breakthroughs**: GANs have advanced fields like medical imaging (synthetic MRI scans) and drug discovery (generating molecular structures).
|
| 95 |
+
- **Trends**: Conditional GANs, diffusion models as alternatives, and GANs for time-series data.
|
| 96 |
+
|
| 97 |
+
#### 3. Everyday Examples
|
| 98 |
+
- **Consumer Apps**: Snapchat and TikTok filters use GANs for face transformations (e.g., aging filters).
|
| 99 |
+
- **Art and Music**: Platforms like Artbreeder let users create art via GANs; Jukebox (OpenAI) generates music.
|
| 100 |
+
- **Social Impact**: GANs raise concerns about deepfakes (synthetic media) but also enable creative tools for content creators.
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
## 🛠️ Phase 3: Hands-On Implementation (40 minutes)
|
| 105 |
+
|
| 106 |
+
### Code Implementation
|
| 107 |
+
|
| 108 |
+
Below are three Python implementations using PyTorch, focusing on GANs for generating MNIST digits. Ensure you have PyTorch and torchvision installed (`pip install torch torchvision`).
|
| 109 |
+
|
| 110 |
+
#### 1. Basic Implementation
|
| 111 |
+
```python
|
| 112 |
+
import torch
|
| 113 |
+
import torch.nn as nn
|
| 114 |
+
import torch.optim as optim
|
| 115 |
+
from torchvision import datasets, transforms
|
| 116 |
+
from torch.utils.data import DataLoader
|
| 117 |
+
import matplotlib.pyplot as plt
|
| 118 |
+
|
| 119 |
+
# Hyperparameters
|
| 120 |
+
latent_dim = 100
|
| 121 |
+
hidden_dim = 256
|
| 122 |
+
image_dim = 784 # 28x28 for MNIST
|
| 123 |
+
num_epochs = 50
|
| 124 |
+
batch_size = 64
|
| 125 |
+
lr = 0.0002
|
| 126 |
+
|
| 127 |
+
# Generator
|
| 128 |
+
class Generator(nn.Module):
|
| 129 |
+
def __init__(self):
|
| 130 |
+
super(Generator, self).__init__()
|
| 131 |
+
self.model = nn.Sequential(
|
| 132 |
+
nn.Linear(latent_dim, hidden_dim),
|
| 133 |
+
nn.ReLU(),
|
| 134 |
+
nn.Linear(hidden_dim, hidden_dim),
|
| 135 |
+
nn.ReLU(),
|
| 136 |
+
nn.Linear(hidden_dim, image_dim),
|
| 137 |
+
nn.Tanh() # Output in [-1, 1]
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
def forward(self, z):
|
| 141 |
+
return self.model(z)
|
| 142 |
+
|
| 143 |
+
# Discriminator
|
| 144 |
+
class Discriminator(nn.Module):
|
| 145 |
+
def __init__(self):
|
| 146 |
+
super(Discriminator, self).__init__()
|
| 147 |
+
self.model = nn.Sequential(
|
| 148 |
+
nn.Linear(image_dim, hidden_dim),
|
| 149 |
+
nn.LeakyReLU(0.2),
|
| 150 |
+
nn.Linear(hidden_dim, hidden_dim),
|
| 151 |
+
nn.LeakyReLU(0.2),
|
| 152 |
+
nn.Linear(hidden_dim, 1),
|
| 153 |
+
nn.Sigmoid() # Output probability
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
def forward(self, x):
|
| 157 |
+
return self.model(x)
|
| 158 |
+
|
| 159 |
+
# Data loading
|
| 160 |
+
transform = transforms.Compose([
|
| 161 |
+
transforms.ToTensor(),
|
| 162 |
+
transforms.Normalize((0.5,), (0.5,)) # Normalize to [-1, 1]
|
| 163 |
+
])
|
| 164 |
+
mnist = datasets.MNIST(root='./data', train=True, transform=transform, download=True)
|
| 165 |
+
dataloader = DataLoader(mnist, batch_size=batch_size, shuffle=True)
|
| 166 |
+
|
| 167 |
+
# Initialize models and optimizers
|
| 168 |
+
generator = Generator()
|
| 169 |
+
discriminator = Discriminator()
|
| 170 |
+
criterion = nn.BCELoss()
|
| 171 |
+
optimizer_g = optim.Adam(generator.parameters(), lr=lr)
|
| 172 |
+
optimizer_d = optim.Adam(discriminator.parameters(), lr=lr)
|
| 173 |
+
|
| 174 |
+
# Training loop
|
| 175 |
+
for epoch in range(num_epochs):
|
| 176 |
+
for i, (real_images, _) in enumerate(dataloader):
|
| 177 |
+
batch_size = real_images.size(0)
|
| 178 |
+
real_images = real_images.view(batch_size, -1)
|
| 179 |
+
|
| 180 |
+
# Labels
|
| 181 |
+
real_labels = torch.ones(batch_size, 1)
|
| 182 |
+
fake_labels = torch.zeros(batch_size, 1)
|
| 183 |
+
|
| 184 |
+
# Train Discriminator
|
| 185 |
+
optimizer_d.zero_grad()
|
| 186 |
+
real_loss = criterion(discriminator(real_images), real_labels)
|
| 187 |
+
z = torch.randn(batch_size, latent_dim)
|
| 188 |
+
fake_images = generator(z)
|
| 189 |
+
fake_loss = criterion(discriminator(fake_images.detach()), fake_labels)
|
| 190 |
+
d_loss = real_loss + fake_loss
|
| 191 |
+
d_loss.backward()
|
| 192 |
+
optimizer_d.step()
|
| 193 |
+
|
| 194 |
+
# Train Generator
|
| 195 |
+
optimizer_g.zero_grad()
|
| 196 |
+
fake_images = generator(z)
|
| 197 |
+
g_loss = criterion(discriminator(fake_images), real_labels) # Trick Discriminator
|
| 198 |
+
g_loss.backward()
|
| 199 |
+
optimizer_g.step()
|
| 200 |
+
|
| 201 |
+
if i % 100 == 0:
|
| 202 |
+
print(f'Epoch [{epoch}/{num_epochs}] Batch [{i}/{len(dataloader)}] '
|
| 203 |
+
f'D Loss: {d_loss.item():.4f}, G Loss: {g_loss.item():.4f}')
|
| 204 |
+
|
| 205 |
+
# Generate and visualize fake images
|
| 206 |
+
z = torch.randn(16, latent_dim)
|
| 207 |
+
fake_images = generator(z).view(-1, 28, 28).detach().numpy()
|
| 208 |
+
plt.figure(figsize=(4, 4))
|
| 209 |
+
for i in range(16):
|
| 210 |
+
plt.subplot(4, 4, i+1)
|
| 211 |
+
plt.imshow(fake_images[i], cmap='gray')
|
| 212 |
+
plt.axis('off')
|
| 213 |
+
plt.show()
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
**Explanation**:
|
| 217 |
+
- **Generator**: Maps noise \( z \) to a 784-dimensional vector (MNIST image).
|
| 218 |
+
- **Discriminator**: Classifies 784-dimensional vectors as real or fake.
|
| 219 |
+
- **Loss**: Uses binary cross-entropy to train both networks.
|
| 220 |
+
- **Training**: Alternates between updating D (to distinguish real vs. fake) and G (to fool D).
|
| 221 |
+
- **Output**: Visualizes 16 generated MNIST digits.
|
| 222 |
+
|
| 223 |
+
#### 2. Real Data Example
|
| 224 |
+
```python
|
| 225 |
+
import torch
|
| 226 |
+
import torch.nn as nn
|
| 227 |
+
import torch.optim as optim
|
| 228 |
+
from torchvision import datasets, transforms
|
| 229 |
+
from torch.utils.data import DataLoader
|
| 230 |
+
import matplotlib.pyplot as plt
|
| 231 |
+
|
| 232 |
+
# Hyperparameters
|
| 233 |
+
latent_dim = 100
|
| 234 |
+
hidden_dim = 256
|
| 235 |
+
image_dim = 784
|
| 236 |
+
num_epochs = 100
|
| 237 |
+
batch_size = 128
|
| 238 |
+
lr = 0.0002
|
| 239 |
+
|
| 240 |
+
# Data loading (MNIST)
|
| 241 |
+
transform = transforms.Compose([
|
| 242 |
+
transforms.ToTensor(),
|
| 243 |
+
transforms.Normalize((0.5,), (0.5,))
|
| 244 |
+
])
|
| 245 |
+
mnist = datasets.MNIST(root='./data', train=True, transform=transform, download=True)
|
| 246 |
+
dataloader = DataLoader(mnist, batch_size=batch_size, shuffle=True)
|
| 247 |
+
|
| 248 |
+
# Same Generator and Discriminator as above
|
| 249 |
+
class Generator(nn.Module):
|
| 250 |
+
def __init__(self):
|
| 251 |
+
super(Generator, self).__init__()
|
| 252 |
+
self.model = nn.Sequential(
|
| 253 |
+
nn.Linear(latent_dim, hidden_dim),
|
| 254 |
+
nn.ReLU(),
|
| 255 |
+
nn.Linear(hidden_dim, hidden_dim),
|
| 256 |
+
nn.ReLU(),
|
| 257 |
+
nn.Linear(hidden_dim, image_dim),
|
| 258 |
+
nn.Tanh()
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
def forward(self, z):
|
| 262 |
+
return self.model(z)
|
| 263 |
+
|
| 264 |
+
class Discriminator(nn.Module):
|
| 265 |
+
def __init__(self):
|
| 266 |
+
super(Discriminator, self).__init__()
|
| 267 |
+
self.model = nn.Sequential(
|
| 268 |
+
nn.Linear(image_dim, hidden_dim),
|
| 269 |
+
nn.LeakyReLU(0.2),
|
| 270 |
+
nn.Linear(hidden_dim, hidden_dim),
|
| 271 |
+
nn.LeakyReLU(0.2),
|
| 272 |
+
nn.Linear(hidden_dim, 1),
|
| 273 |
+
nn.Sigmoid()
|
| 274 |
+
)
|
| 275 |
+
|
| 276 |
+
def forward(self, x):
|
| 277 |
+
return self.model(x)
|
| 278 |
+
|
| 279 |
+
# Initialize models and optimizers
|
| 280 |
+
generator = Generator()
|
| 281 |
+
discriminator = Discriminator()
|
| 282 |
+
criterion = nn.BCELoss()
|
| 283 |
+
optimizer_g = optim.Adam(generator.parameters(), lr=lr, betas=(0.5, 0.999))
|
| 284 |
+
optimizer_d = optim.Adam(discriminator.parameters(), lr=lr, betas=(0.5, 0.999))
|
| 285 |
+
|
| 286 |
+
# Training loop with visualization
|
| 287 |
+
losses_g, losses_d = [], []
|
| 288 |
+
for epoch in range(num_epochs):
|
| 289 |
+
for real_images, _ in dataloader:
|
| 290 |
+
batch_size = real_images.size(0)
|
| 291 |
+
real_images = real_images.view(batch_size, -1)
|
| 292 |
+
|
| 293 |
+
# Train Discriminator
|
| 294 |
+
optimizer_d.zero_grad()
|
| 295 |
+
real_loss = criterion(discriminator(real_images), torch.ones(batch_size, 1))
|
| 296 |
+
z = torch.randn(batch_size, latent_dim)
|
| 297 |
+
fake_images = generator(z)
|
| 298 |
+
fake_loss = criterion(discriminator(fake_images.detach()), torch.zeros(batch_size, 1))
|
| 299 |
+
d_loss = real_loss + fake_loss
|
| 300 |
+
d_loss.backward()
|
| 301 |
+
optimizer_d.step()
|
| 302 |
+
|
| 303 |
+
# Train Generator
|
| 304 |
+
optimizer_g.zero_grad()
|
| 305 |
+
fake_images = generator(z)
|
| 306 |
+
g_loss = criterion(discriminator(fake_images), torch.ones(batch_size, 1))
|
| 307 |
+
g_loss.backward()
|
| 308 |
+
optimizer_g.step()
|
| 309 |
+
|
| 310 |
+
losses_g.append(g_loss.item())
|
| 311 |
+
losses_d.append(d_loss.item())
|
| 312 |
+
|
| 313 |
+
print(f'Epoch [{epoch+1}/{num_epochs}] D Loss: {d_loss.item():.4f}, G Loss: {g_loss.item():.4f}')
|
| 314 |
+
|
| 315 |
+
# Plot losses
|
| 316 |
+
plt.figure(figsize=(10, 5))
|
| 317 |
+
plt.plot(losses_d, label='Discriminator Loss')
|
| 318 |
+
plt.plot(losses_g, label='Generator Loss')
|
| 319 |
+
plt.xlabel('Iteration')
|
| 320 |
+
plt.ylabel('Loss')
|
| 321 |
+
plt.legend()
|
| 322 |
+
plt.show()
|
| 323 |
+
|
| 324 |
+
# Generate and visualize results
|
| 325 |
+
z = torch.randn(16, latent_dim)
|
| 326 |
+
fake_images = generator(z).view(-1, 28, 28).detach().numpy()
|
| 327 |
+
plt.figure(figsize=(4, 4))
|
| 328 |
+
for i in range(16):
|
| 329 |
+
plt.subplot(4, 4, i+1)
|
| 330 |
+
plt.imshow(fake_images[i], cmap='gray')
|
| 331 |
+
plt.axis('off')
|
| 332 |
+
plt.show()
|
| 333 |
+
```
|
| 334 |
+
|
| 335 |
+
**Explanation**:
|
| 336 |
+
- **Dataset**: Uses MNIST (28x28 grayscale digit images).
|
| 337 |
+
- **Preprocessing**: Normalizes images to [-1, 1].
|
| 338 |
+
- **Pipeline**: Loads data, trains GAN, and visualizes both losses and generated images.
|
| 339 |
+
- **Visualization**: Plots D and G losses to monitor training stability and shows generated digits.
|
| 340 |
+
|
| 341 |
+
#### 3. Advanced Implementation (DCGAN)
|
| 342 |
+
```python
|
| 343 |
+
import torch
|
| 344 |
+
import torch.nn as nn
|
| 345 |
+
import torch.optim as optim
|
| 346 |
+
from torchvision import datasets, transforms
|
| 347 |
+
from torch.utils.data import DataLoader
|
| 348 |
+
import matplotlib.pyplot as plt
|
| 349 |
+
|
| 350 |
+
# Hyperparameters
|
| 351 |
+
latent_dim = 100
|
| 352 |
+
num_epochs = 100
|
| 353 |
+
batch_size = 128
|
| 354 |
+
lr = 0.0002
|
| 355 |
+
image_size = 64
|
| 356 |
+
channels = 1 # Grayscale for MNIST
|
| 357 |
+
|
| 358 |
+
# Data loading with resizing
|
| 359 |
+
transform = transforms.Compose([
|
| 360 |
+
transforms.Resize(image_size),
|
| 361 |
+
transforms.ToTensor(),
|
| 362 |
+
transforms.Normalize((0.5,), (0.5,))
|
| 363 |
+
])
|
| 364 |
+
mnist = datasets.MNIST(root='./data', train=True, transform=transform, download=True)
|
| 365 |
+
dataloader = DataLoader(mnist, batch_size=batch_size, shuffle=True)
|
| 366 |
+
|
| 367 |
+
# Generator (DCGAN)
|
| 368 |
+
class Generator(nn.Module):
|
| 369 |
+
def __init__(self):
|
| 370 |
+
super(Generator, self).__init__()
|
| 371 |
+
self.model = nn.Sequential(
|
| 372 |
+
nn.ConvTranspose2d(latent_dim, 512, 4, 1, 0, bias=False),
|
| 373 |
+
nn.BatchNorm2d(512),
|
| 374 |
+
nn.ReLU(True),
|
| 375 |
+
nn.ConvTranspose2d(512, 256, 4, 2, 1, bias=False),
|
| 376 |
+
nn.BatchNorm2d(256),
|
| 377 |
+
nn.ReLU(True),
|
| 378 |
+
nn.ConvTranspose2d(256, 128, 4, 2, 1, bias=False),
|
| 379 |
+
nn.BatchNorm2d(128),
|
| 380 |
+
nn.ReLU(True),
|
| 381 |
+
nn.ConvTranspose2d(128, channels, 4, 2, 1, bias=False),
|
| 382 |
+
nn.Tanh()
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
def forward(self, z):
|
| 386 |
+
z = z.view(-1, latent_dim, 1, 1)
|
| 387 |
+
return self.model(z)
|
| 388 |
+
|
| 389 |
+
# Discriminator (DCGAN)
|
| 390 |
+
class Discriminator(nn.Module):
|
| 391 |
+
def __init__(self):
|
| 392 |
+
super(Discriminator, self).__init__()
|
| 393 |
+
self.model = nn.Sequential(
|
| 394 |
+
nn.Conv2d(channels, 128, 4, 2, 1, bias=False),
|
| 395 |
+
nn.LeakyReLU(0.2, inplace=True),
|
| 396 |
+
nn.Conv2d(128, 256, 4, 2, 1, bias=False),
|
| 397 |
+
nn.BatchNorm2d(256),
|
| 398 |
+
nn.LeakyReLU(0.2, inplace=True),
|
| 399 |
+
nn.Conv2d(256, 512, 4, 2, 1, bias=False),
|
| 400 |
+
nn.BatchNorm2d(512),
|
| 401 |
+
nn.LeakyReLU(0.2, inplace=True),
|
| 402 |
+
nn.Conv2d(512, 1, 4, 1, 0, bias=False),
|
| 403 |
+
nn.Sigmoid()
|
| 404 |
+
)
|
| 405 |
+
|
| 406 |
+
def forward(self, x):
|
| 407 |
+
return self.model(x).view(-1, 1)
|
| 408 |
+
|
| 409 |
+
# Initialize models and optimizers
|
| 410 |
+
generator = Generator()
|
| 411 |
+
discriminator = Discriminator()
|
| 412 |
+
criterion = nn.BCELoss()
|
| 413 |
+
optimizer_g = optim.Adam(generator.parameters(), lr=lr, betas=(0.5, 0.999))
|
| 414 |
+
optimizer_d = optim.Adam(discriminator.parameters(), lr=lr, betas=(0.5, 0.999))
|
| 415 |
+
|
| 416 |
+
# Training loop
|
| 417 |
+
for epoch in range(num_epochs):
|
| 418 |
+
for real_images, _ in dataloader:
|
| 419 |
+
batch_size = real_images.size(0)
|
| 420 |
+
|
| 421 |
+
# Train Discriminator
|
| 422 |
+
optimizer_d.zero_grad()
|
| 423 |
+
real_loss = criterion(discriminator(real_images), torch.ones(batch_size, 1))
|
| 424 |
+
z = torch.randn(batch_size, latent_dim)
|
| 425 |
+
fake_images = generator(z)
|
| 426 |
+
fake_loss = criterion(discriminator(fake_images.detach()), torch.zeros(batch_size, 1))
|
| 427 |
+
d_loss = real_loss + fake_loss
|
| 428 |
+
d_loss.backward()
|
| 429 |
+
optimizer_d.step()
|
| 430 |
+
|
| 431 |
+
# Train Generator
|
| 432 |
+
optimizer_g.zero_grad()
|
| 433 |
+
fake_images = generator(z)
|
| 434 |
+
g_loss = criterion(discriminator(fake_images), torch.ones(batch_size, 1))
|
| 435 |
+
g_loss.backward()
|
| 436 |
+
optimizer_g.step()
|
| 437 |
+
|
| 438 |
+
print(f'Epoch [{epoch+1}/{num_epochs}] D Loss: {d_loss.item():.4f}, G Loss: {g_loss.item():.4f}')
|
| 439 |
+
|
| 440 |
+
# Generate and visualize
|
| 441 |
+
z = torch.randn(16, latent_dim)
|
| 442 |
+
fake_images = generator(z).view(-1, channels, image_size, image_size).detach().numpy()
|
| 443 |
+
plt.figure(figsize=(4, 4))
|
| 444 |
+
for i in range(16):
|
| 445 |
+
plt.subplot(4, 4, i+1)
|
| 446 |
+
plt.imshow(fake_images[i, 0], cmap='gray')
|
| 447 |
+
plt.axis('off')
|
| 448 |
+
plt.show()
|
| 449 |
+
```
|
| 450 |
+
|
| 451 |
+
**Explanation**:
|
| 452 |
+
- **DCGAN**: Uses convolutional layers (ConvTranspose2d for Generator, Conv2d for Discriminator) for better image generation.
|
| 453 |
+
- **Improvements**: Adds batch normalization and LeakyReLU for stability, resizes MNIST to 64x64 for deeper networks.
|
| 454 |
+
- **Hyperparameters**: Tuned betas for Adam optimizer to stabilize training.
|
| 455 |
+
- **Libraries**: Leverages PyTorch’s convolutional layers and batch normalization.
|
| 456 |
+
|
| 457 |
+
### Interactive Experimentation
|
| 458 |
+
|
| 459 |
+
#### 1. Parameter Sensitivity Analysis
|
| 460 |
+
- **Experiment**: Vary `latent_dim` (e.g., 50, 100, 200) and observe the quality of generated images.
|
| 461 |
+
- Smaller `latent_dim`: Less diversity in generated images.
|
| 462 |
+
- Larger `latent_dim`: More diverse but harder to train.
|
| 463 |
+
- **Experiment**: Adjust learning rate (`lr = 0.001, 0.0002, 0.00005`) and monitor D/G loss convergence.
|
| 464 |
+
- High `lr`: Unstable training, oscillating losses.
|
| 465 |
+
- Low `lr`: Slower convergence but more stable.
|
| 466 |
+
|
| 467 |
+
#### 2. Comparison Experiments
|
| 468 |
+
- **Compare with VAE**:
|
| 469 |
+
- Train a Variational Autoencoder on MNIST and compare image quality.
|
| 470 |
+
- GANs typically produce sharper images; VAEs produce blurrier but more stable outputs.
|
| 471 |
+
- **Strengths**: GANs excel at generating high-quality, realistic samples.
|
| 472 |
+
- **Weaknesses**: Prone to mode collapse and training instability.
|
| 473 |
+
|
| 474 |
+
#### 3. Failure Case Analysis
|
| 475 |
+
- **Common Issues**:
|
| 476 |
+
- **Mode Collapse**: Generator produces similar images (e.g., only one digit). Fix: Use Wasserstein GAN or add diversity-promoting loss.
|
| 477 |
+
- **Non-Convergence**: D or G becomes too strong. Fix: Balance training (e.g., train D fewer times than G).
|
| 478 |
+
- **Debugging**:
|
| 479 |
+
- Monitor D and G losses: If D loss → 0, G isn’t learning; if G loss → 0, D is too weak.
|
| 480 |
+
- Visualize generated images regularly to check quality.
|
| 481 |
+
- Use gradient clipping or label smoothing to stabilize training.
|
| 482 |
+
|
| 483 |
+
---
|
| 484 |
+
|
| 485 |
+
## 📊 Phase 4: Performance Analysis (15 minutes)
|
| 486 |
+
|
| 487 |
+
### Evaluation Metrics
|
| 488 |
+
|
| 489 |
+
#### 1. Quantitative Metrics
|
| 490 |
+
- **Inception Score (IS)**: Measures quality and diversity of generated images (higher is better). Requires a pre-trained classifier (e.g., Inception V3).
|
| 491 |
+
- **Fréchet Inception Distance (FID)**: Compares feature distributions of real and fake images (lower is better). Formula:
|
| 492 |
+
\[
|
| 493 |
+
\text{FID} = ||\mu_r - \mu_g||^2 + \text{Tr}(\Sigma_r + \Sigma_g - 2(\Sigma_r \Sigma_g)^{1/2})
|
| 494 |
+
\]
|
| 495 |
+
where \( \mu_r, \mu_g \) are mean feature vectors, and \( \Sigma_r, \Sigma_g \) are covariance matrices.
|
| 496 |
+
- **Precision/Recall**: Measures coverage of real data distribution and quality of generated samples.
|
| 497 |
+
|
| 498 |
+
#### 2. Qualitative Assessment
|
| 499 |
+
- **Visual Inspection**: Check if generated images are realistic, diverse, and free of artifacts.
|
| 500 |
+
- **Human Evaluation**: Ask humans to distinguish real vs. fake images or rate quality.
|
| 501 |
+
- **Consistency**: Ensure generated samples align with the target domain (e.g., digits resemble MNIST).
|
| 502 |
+
|
| 503 |
+
#### 3. Benchmarking
|
| 504 |
+
- **Comparison**: GANs outperform VAEs in image quality but are harder to train. Diffusion models (e.g., DALL-E 2) may produce better results but are slower.
|
| 505 |
+
- **Trade-offs**:
|
| 506 |
+
- GANs: High-quality outputs, unstable training.
|
| 507 |
+
- VAEs: Stable training, blurrier outputs.
|
| 508 |
+
- Diffusion Models: High quality, computationally expensive.
|
| 509 |
+
|
| 510 |
+
---
|
| 511 |
+
|
| 512 |
+
## 🎯 Phase 5: Use Cases and Applications (15 minutes)
|
| 513 |
+
|
| 514 |
+
### Practical Scenarios
|
| 515 |
+
|
| 516 |
+
#### 1. Business Applications
|
| 517 |
+
- **Marketing**: Generate realistic product images for e-commerce (e.g., Zalando uses GANs for virtual clothing).
|
| 518 |
+
- **Entertainment**: Create synthetic characters or environments for games and movies (e.g., NVIDIA’s DLSS).
|
| 519 |
+
- **ROI**: Reduces costs for content creation (e.g., no need for physical photoshoots) and enables personalized marketing.
|
| 520 |
+
|
| 521 |
+
#### 2. Research Applications
|
| 522 |
+
- **Medical Imaging**: Generate synthetic CT/MRI scans to augment datasets (e.g., GANs for brain tumor imaging).
|
| 523 |
+
- **Data Augmentation**: Create synthetic data for rare events in anomaly detection.
|
| 524 |
+
- **Cutting-Edge**: Conditional GANs for controlled generation (e.g., text-to-image synthesis).
|
| 525 |
+
|
| 526 |
+
#### 3. Personal Projects
|
| 527 |
+
- **Portfolio Ideas**:
|
| 528 |
+
- Build a GAN to generate custom artwork based on user sketches.
|
| 529 |
+
- Create a text-to-image GAN using a dataset like CIFAR-10.
|
| 530 |
+
- Develop a music generation GAN using MIDI data.
|
| 531 |
+
- **Experimentation**: Try CycleGAN for style transfer (e.g., photos to paintings) or implement a conditional GAN for specific digit generation.
|
| 532 |
+
|
| 533 |
+
---
|
| 534 |
+
|
| 535 |
+
## 📚 Phase 6: Deep Dive Resources (10 minutes)
|
| 536 |
+
|
| 537 |
+
### Further Learning
|
| 538 |
+
|
| 539 |
+
#### 1. Academic Papers
|
| 540 |
+
- **Foundational**: “Generative Adversarial Nets” (Goodfellow et al., 2014).
|
| 541 |
+
- **Breakthroughs**:
|
| 542 |
+
- “Unsupervised Representation Learning with Deep Convolutional GANs” (Radford et al., 2015).
|
| 543 |
+
- “Conditional Generative Adversarial Nets” (Mirza & Osindero, 2014).
|
| 544 |
+
- **Survey**: “Generative Adversarial Networks: An Overview” (Creswell et al., 2018).
|
| 545 |
+
|
| 546 |
+
#### 2. Books and Courses
|
| 547 |
+
- **Books**:
|
| 548 |
+
- “Deep Learning” by Goodfellow, Bengio, and Courville (Chapter on GANs).
|
| 549 |
+
- “Generative Deep Learning” by David Foster.
|
| 550 |
+
- **Courses**:
|
| 551 |
+
- Coursera: “Generative Adversarial Networks (GANs) Specialization” by DeepLearning.AI.
|
| 552 |
+
- Stanford CS231n (Convolutional Neural Networks for Visual Recognition) – GAN lectures.
|
| 553 |
+
- **Videos**: Ian Goodfellow’s talks on YouTube (e.g., “GANs: Past, Present, and Future”).
|
| 554 |
+
|
| 555 |
+
#### 3. Code Repositories
|
| 556 |
+
- **GitHub**:
|
| 557 |
+
- tensorflow/gan: Official TensorFlow GAN implementations.
|
| 558 |
+
- eriklindernoren/PyTorch-GAN: PyTorch implementations of various GANs.
|
| 559 |
+
- NVIDIA/StyleGAN: High-quality image generation code.
|
| 560 |
+
- **Research Code**: Check arXiv for open-source GAN implementations linked to recent papers.
|
| 561 |
+
|
| 562 |
+
---
|
| 563 |
+
|
| 564 |
+
## 🎯 Learning Checklist
|
| 565 |
+
- [ ] I can explain the mathematical foundations (minimax objective, Nash equilibrium).
|
| 566 |
+
- [ ] I understand the core algorithms (alternating training of G and D).
|
| 567 |
+
- [ ] I can implement a basic GAN from scratch (see code above).
|
| 568 |
+
- [ ] I can apply GANs to real data (MNIST example).
|
| 569 |
+
- [ ] I understand use cases (image generation, data augmentation) and limitations (mode collapse, instability).
|
| 570 |
+
- [ ] I can compare GANs to VAEs and diffusion models.
|
| 571 |
+
- [ ] I have experimented with parameters (latent_dim, lr).
|
| 572 |
+
- [ ] I can troubleshoot issues (monitor losses, visualize outputs).
|
| 573 |
+
|
| 574 |
+
---
|
| 575 |
+
|
| 576 |
+
This completes the comprehensive learning prompt for GANs. You’re now equipped with the mathematical foundations, practical examples, code implementations, and resources to dive deeper. Let me know if you want to focus on a specific aspect (e.g., advanced GAN variants like WGAN or CycleGAN) or need help running the code!
|
README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GAN Implementation - MNIST Digit Generation
|
| 2 |
+
|
| 3 |
+
A comprehensive implementation of Generative Adversarial Networks (GANs) for generating MNIST handwritten digits using PyTorch.
|
| 4 |
+
|
| 5 |
+
## 🔥 Features
|
| 6 |
+
|
| 7 |
+
- **Complete GAN Implementation**: Both standard and optimized versions
|
| 8 |
+
- **MNIST Digit Generation**: Generate realistic handwritten digits
|
| 9 |
+
- **Multiple Training Modes**: Standard and lite modes for different performance needs
|
| 10 |
+
- **Comprehensive Logging**: Detailed training logs and progress tracking
|
| 11 |
+
- **GPU Support**: MPS (Apple Silicon), CUDA, and CPU support
|
| 12 |
+
- **Visualization**: Real-time training progress and generated samples
|
| 13 |
+
|
| 14 |
+
## 📊 Results
|
| 15 |
+
|
| 16 |
+
The implementation successfully generates realistic MNIST digits with:
|
| 17 |
+
- **Generator Parameters**: 576K (lite) / 3.5M (standard)
|
| 18 |
+
- **Discriminator Parameters**: 533K (lite) / 2.7M (standard)
|
| 19 |
+
- **Training Time**: ~5 minutes (lite mode) / ~30 minutes (standard)
|
| 20 |
+
|
| 21 |
+
## 🚀 Quick Start
|
| 22 |
+
|
| 23 |
+
### Installation
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
# Clone the repository
|
| 27 |
+
git clone https://github.com/GruheshKurra/GAN_Implementation.git
|
| 28 |
+
cd GAN_Implementation
|
| 29 |
+
|
| 30 |
+
# Install dependencies
|
| 31 |
+
pip install -r requirements.txt
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
### Usage
|
| 35 |
+
|
| 36 |
+
1. **Open the Jupyter Notebook**:
|
| 37 |
+
```bash
|
| 38 |
+
jupyter notebook Gan.ipynb
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
2. **Run the cells** to train the GAN and generate digits
|
| 42 |
+
|
| 43 |
+
3. **Choose your mode**:
|
| 44 |
+
- **Standard Mode**: Full implementation with detailed logging
|
| 45 |
+
- **Lite Mode**: Optimized for faster training and lower resource usage
|
| 46 |
+
|
| 47 |
+
## 📁 Project Structure
|
| 48 |
+
|
| 49 |
+
```
|
| 50 |
+
GAN_Implementation/
|
| 51 |
+
├── Gan.ipynb # Main implementation notebook
|
| 52 |
+
├── requirements.txt # Python dependencies
|
| 53 |
+
├── README.md # This file
|
| 54 |
+
├── Generative Adversarial Networks (GANs).md # Theory and documentation
|
| 55 |
+
├── gan_training.log # Training logs (standard mode)
|
| 56 |
+
├── gan_training_lite.log # Training logs (lite mode)
|
| 57 |
+
├── generator_lite.pth # Saved model weights
|
| 58 |
+
└── data/ # MNIST dataset
|
| 59 |
+
└── MNIST/
|
| 60 |
+
└── raw/ # Raw MNIST data files
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## 🧠 Implementation Details
|
| 64 |
+
|
| 65 |
+
### Architecture
|
| 66 |
+
|
| 67 |
+
**Generator Network**:
|
| 68 |
+
- Input: Random noise vector (100D standard / 64D lite)
|
| 69 |
+
- Hidden layers with ReLU/BatchNorm activation
|
| 70 |
+
- Output: 784D vector (28x28 MNIST image)
|
| 71 |
+
- Activation: Tanh (output range [-1, 1])
|
| 72 |
+
|
| 73 |
+
**Discriminator Network**:
|
| 74 |
+
- Input: 784D image vector
|
| 75 |
+
- Hidden layers with LeakyReLU/Dropout
|
| 76 |
+
- Output: Single probability (real vs fake)
|
| 77 |
+
- Activation: Sigmoid
|
| 78 |
+
|
| 79 |
+
### Training Process
|
| 80 |
+
|
| 81 |
+
1. **Data Preparation**: MNIST dataset normalized to [-1, 1]
|
| 82 |
+
2. **Adversarial Training**:
|
| 83 |
+
- Discriminator learns to distinguish real vs fake images
|
| 84 |
+
- Generator learns to fool the discriminator
|
| 85 |
+
3. **Loss Function**: Binary Cross-Entropy Loss
|
| 86 |
+
4. **Optimization**: Adam optimizer with β₁=0.5, β₂=0.999
|
| 87 |
+
|
| 88 |
+
## 📈 Training Modes
|
| 89 |
+
|
| 90 |
+
### Standard Mode
|
| 91 |
+
- **Latent Dimension**: 100
|
| 92 |
+
- **Epochs**: 50-100
|
| 93 |
+
- **Batch Size**: 64-128
|
| 94 |
+
- **Dataset**: Full MNIST (60K samples)
|
| 95 |
+
- **Best for**: High-quality results
|
| 96 |
+
|
| 97 |
+
### Lite Mode
|
| 98 |
+
- **Latent Dimension**: 64
|
| 99 |
+
- **Epochs**: 50
|
| 100 |
+
- **Batch Size**: 64
|
| 101 |
+
- **Dataset**: Subset (10K samples)
|
| 102 |
+
- **Best for**: Quick experimentation and testing
|
| 103 |
+
|
| 104 |
+
## 🔧 Technical Features
|
| 105 |
+
|
| 106 |
+
- **Device Auto-Detection**: Automatically uses MPS, CUDA, or CPU
|
| 107 |
+
- **Memory Optimization**: Efficient memory usage with cache clearing
|
| 108 |
+
- **Progress Tracking**: Real-time loss monitoring and sample generation
|
| 109 |
+
- **Model Persistence**: Save/load trained models
|
| 110 |
+
- **Comprehensive Logging**: Detailed training metrics and timing
|
| 111 |
+
|
| 112 |
+
## 📊 Performance Metrics
|
| 113 |
+
|
| 114 |
+
| Mode | Training Time | Generator Loss | Discriminator Loss | Quality |
|
| 115 |
+
|------|---------------|----------------|-------------------|---------|
|
| 116 |
+
| Standard | ~30 min | ~1.5 | ~0.7 | High |
|
| 117 |
+
| Lite | ~5 min | ~2.0 | ~0.6 | Good |
|
| 118 |
+
|
| 119 |
+
## 🎯 Use Cases
|
| 120 |
+
|
| 121 |
+
- **Educational**: Learn GAN fundamentals with working code
|
| 122 |
+
- **Research**: Baseline for GAN experiments
|
| 123 |
+
- **Prototyping**: Quick testing of GAN modifications
|
| 124 |
+
- **Production**: Scalable digit generation system
|
| 125 |
+
|
| 126 |
+
## 🔗 Links & Resources
|
| 127 |
+
|
| 128 |
+
- **GitHub Repository**: [https://github.com/GruheshKurra/GAN_Implementation](https://github.com/GruheshKurra/GAN_Implementation)
|
| 129 |
+
- **Hugging Face**: [https://huggingface.co/karthik-2905/GAN_Implementation](https://huggingface.co/karthik-2905/GAN_Implementation)
|
| 130 |
+
- **Blog Post**: [Coming Soon on daily.dev]
|
| 131 |
+
- **Theory Documentation**: See `Generative Adversarial Networks (GANs).md`
|
| 132 |
+
|
| 133 |
+
## 🛠️ Requirements
|
| 134 |
+
|
| 135 |
+
- Python 3.7+
|
| 136 |
+
- PyTorch 2.0+
|
| 137 |
+
- torchvision 0.15+
|
| 138 |
+
- matplotlib 3.5+
|
| 139 |
+
- numpy 1.21+
|
| 140 |
+
- jupyter 1.0+
|
| 141 |
+
|
| 142 |
+
## 📝 License
|
| 143 |
+
|
| 144 |
+
This project is open source and available under the MIT License.
|
| 145 |
+
|
| 146 |
+
## 🤝 Contributing
|
| 147 |
+
|
| 148 |
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
| 149 |
+
|
| 150 |
+
## 📞 Contact
|
| 151 |
+
|
| 152 |
+
- **Author**: Karthik
|
| 153 |
+
- **GitHub**: [@GruheshKurra](https://github.com/GruheshKurra)
|
| 154 |
+
|
| 155 |
+
## 🙏 Acknowledgments
|
| 156 |
+
|
| 157 |
+
- Original GAN paper by Ian Goodfellow et al.
|
| 158 |
+
- PyTorch team for the excellent deep learning framework
|
| 159 |
+
- MNIST dataset creators
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
|
| 163 |
+
**⭐ If you find this implementation helpful, please give it a star!**
|
data/MNIST/raw/t10k-images-idx3-ubyte
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0fa7898d509279e482958e8ce81c8e77db3f2f8254e26661ceb7762c4d494ce7
|
| 3 |
+
size 7840016
|
data/MNIST/raw/t10k-images-idx3-ubyte.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8d422c7b0a1c1c79245a5bcf07fe86e33eeafee792b84584aec276f5a2dbc4e6
|
| 3 |
+
size 1648877
|
data/MNIST/raw/t10k-labels-idx1-ubyte
ADDED
|
Binary file (10 kB). View file
|
|
|
data/MNIST/raw/t10k-labels-idx1-ubyte.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f7ae60f92e00ec6debd23a6088c31dbd2371eca3ffa0defaefb259924204aec6
|
| 3 |
+
size 4542
|
data/MNIST/raw/train-images-idx3-ubyte
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba891046e6505d7aadcbbe25680a0738ad16aec93bde7f9b65e87a2fc25776db
|
| 3 |
+
size 47040016
|
data/MNIST/raw/train-images-idx3-ubyte.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:440fcabf73cc546fa21475e81ea370265605f56be210a4024d2ca8f203523609
|
| 3 |
+
size 9912422
|
data/MNIST/raw/train-labels-idx1-ubyte
ADDED
|
Binary file (60 kB). View file
|
|
|
data/MNIST/raw/train-labels-idx1-ubyte.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3552534a0a558bbed6aed32b30c495cca23d567ec52cac8be1a0730e8010255c
|
| 3 |
+
size 28881
|
gan_training.log
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2025-07-13 11:18:33,402 - INFO - Using device: cpu
|
| 2 |
+
2025-07-13 11:18:33,403 - INFO - Hyperparameters - Latent dim: 100, Epochs: 100, Batch size: 128, LR: 0.0002
|
| 3 |
+
2025-07-13 11:18:33,404 - INFO - Loading MNIST dataset...
|
| 4 |
+
2025-07-13 11:20:17,010 - INFO - Using MPS (Metal Performance Shaders) for GPU acceleration
|
| 5 |
+
2025-07-13 11:20:17,011 - INFO - Device: mps
|
| 6 |
+
2025-07-13 11:20:17,011 - INFO - Hyperparameters - Latent dim: 100, Epochs: 100, Batch size: 128, LR: 0.0002
|
| 7 |
+
2025-07-13 11:20:17,011 - INFO - Loading MNIST dataset...
|
| 8 |
+
2025-07-13 11:20:27,813 - INFO - Dataset loaded - Total samples: 60000, Batches per epoch: 469
|
| 9 |
+
2025-07-13 11:20:27,814 - INFO - DataLoader optimized with 4 workers and memory pinning for faster data transfer
|
| 10 |
+
2025-07-13 11:20:27,815 - INFO - Creating and initializing models...
|
| 11 |
+
2025-07-13 11:20:27,815 - INFO - Initializing Generator architecture...
|
| 12 |
+
2025-07-13 11:20:27,824 - INFO - Generator architecture complete - Output shape: (batch_size, 1, 64, 64)
|
| 13 |
+
2025-07-13 11:20:27,866 - INFO - Initializing Discriminator architecture...
|
| 14 |
+
2025-07-13 11:20:27,871 - INFO - Discriminator architecture complete - Output: Real/Fake probability
|
| 15 |
+
2025-07-13 11:20:27,875 - INFO - Generator parameters: 3,574,656
|
| 16 |
+
2025-07-13 11:20:27,876 - INFO - Discriminator parameters: 2,763,520
|
| 17 |
+
2025-07-13 11:20:27,876 - INFO - Models moved to MPS (Apple Silicon GPU)
|
| 18 |
+
2025-07-13 11:20:27,876 - INFO - Note: MPS provides significant acceleration for matrix operations on M-series chips
|
| 19 |
+
2025-07-13 11:20:27,877 - INFO - Applying weight initialization...
|
| 20 |
+
2025-07-13 11:20:28,177 - INFO - Optimizers initialized with Adam (lr=0.0002, betas=(0.5, 0.999))
|
| 21 |
+
2025-07-13 11:20:28,228 - INFO - Fixed noise vector created for consistent progress tracking
|
| 22 |
+
2025-07-13 11:20:28,229 - INFO - ============================================================
|
| 23 |
+
2025-07-13 11:20:28,229 - INFO - STARTING TRAINING ON MPS (APPLE SILICON GPU)
|
| 24 |
+
2025-07-13 11:20:28,229 - INFO - ============================================================
|
| 25 |
+
2025-07-13 11:20:28,230 - INFO - Starting Epoch 1/100
|
| 26 |
+
2025-07-13 11:20:32,930 - INFO - Epoch [1/100] Batch [1/469] D_Loss: 2.2925 G_Loss: 2.4867 D_Real: 0.2779 D_Fake: 0.4786 Time: 3.036s (42.2 img/s)
|
| 27 |
+
2025-07-13 11:20:46,893 - INFO - Epoch [1/100] Batch [101/469] D_Loss: 0.1327 G_Loss: 5.0302 D_Real: 0.9274 D_Fake: 0.0380 Time: 0.139s (919.6 img/s)
|
| 28 |
+
2025-07-13 11:21:00,856 - INFO - Epoch [1/100] Batch [201/469] D_Loss: 0.0768 G_Loss: 5.0648 D_Real: 0.9507 D_Fake: 0.0206 Time: 0.140s (917.3 img/s)
|
| 29 |
+
2025-07-13 11:22:12,887 - INFO - Using MPS (optimized for efficiency)
|
| 30 |
+
2025-07-13 11:22:12,888 - INFO - LITE MODE - Latent: 64, Epochs: 50, Batch: 64, Subset: 10000
|
| 31 |
+
2025-07-13 11:22:12,889 - INFO - Loading MNIST subset...
|
| 32 |
+
2025-07-13 11:22:12,906 - INFO - Using 10000 samples, 157 batches per epoch
|
| 33 |
+
2025-07-13 11:22:12,908 - INFO - Simple Generator: Linear layers only (much faster)
|
| 34 |
+
2025-07-13 11:22:12,931 - INFO - Simple Discriminator: Linear layers only (much faster)
|
| 35 |
+
2025-07-13 11:22:12,934 - INFO - Generator params: 576,656 (vs 3.5M before)
|
| 36 |
+
2025-07-13 11:22:12,934 - INFO - Discriminator params: 533,505 (vs 2.7M before)
|
| 37 |
+
2025-07-13 11:22:12,938 - INFO - ==================================================
|
| 38 |
+
2025-07-13 11:22:12,938 - INFO - STARTING LITE TRAINING (HEAT OPTIMIZED)
|
| 39 |
+
2025-07-13 11:22:12,938 - INFO - ==================================================
|
| 40 |
+
2025-07-13 11:22:15,868 - INFO - Epoch [1/50] Batch [1/157] D_Loss: 1.414 G_Loss: 0.727
|
| 41 |
+
2025-07-13 11:22:16,196 - INFO - Epoch [1/50] Batch [51/157] D_Loss: 0.487 G_Loss: 1.930
|
| 42 |
+
2025-07-13 11:22:16,509 - INFO - Epoch [1/50] Batch [101/157] D_Loss: 0.087 G_Loss: 5.107
|
| 43 |
+
2025-07-13 11:22:16,822 - INFO - Epoch [1/50] Batch [151/157] D_Loss: 0.188 G_Loss: 9.829
|
| 44 |
+
2025-07-13 11:22:17,650 - INFO - Epoch 1 - D_Loss: 0.499, G_Loss: 3.914, Time: 4.7s
|
| 45 |
+
2025-07-13 11:22:18,681 - INFO - Epoch [2/50] Batch [1/157] D_Loss: 0.198 G_Loss: 10.054
|
| 46 |
+
2025-07-13 11:22:19,003 - INFO - Epoch [2/50] Batch [51/157] D_Loss: 0.197 G_Loss: 10.293
|
| 47 |
+
2025-07-13 11:22:19,325 - INFO - Epoch [2/50] Batch [101/157] D_Loss: 0.107 G_Loss: 3.773
|
| 48 |
+
2025-07-13 11:22:19,643 - INFO - Epoch [2/50] Batch [151/157] D_Loss: 0.120 G_Loss: 4.523
|
| 49 |
+
2025-07-13 11:22:19,939 - INFO - Epoch 2 - D_Loss: 0.149, G_Loss: 8.121, Time: 2.2s
|
| 50 |
+
2025-07-13 11:22:20,903 - INFO - Epoch [3/50] Batch [1/157] D_Loss: 0.090 G_Loss: 4.251
|
| 51 |
+
2025-07-13 11:22:21,220 - INFO - Epoch [3/50] Batch [51/157] D_Loss: 0.055 G_Loss: 5.018
|
| 52 |
+
2025-07-13 11:22:21,535 - INFO - Epoch [3/50] Batch [101/157] D_Loss: 0.037 G_Loss: 6.808
|
| 53 |
+
2025-07-13 11:22:21,853 - INFO - Epoch [3/50] Batch [151/157] D_Loss: 0.025 G_Loss: 6.606
|
| 54 |
+
2025-07-13 11:22:22,134 - INFO - Epoch 3 - D_Loss: 0.050, G_Loss: 5.622, Time: 2.2s
|
| 55 |
+
2025-07-13 11:22:23,103 - INFO - Epoch [4/50] Batch [1/157] D_Loss: 0.020 G_Loss: 6.747
|
| 56 |
+
2025-07-13 11:22:23,420 - INFO - Epoch [4/50] Batch [51/157] D_Loss: 0.016 G_Loss: 6.293
|
| 57 |
+
2025-07-13 11:22:23,732 - INFO - Epoch [4/50] Batch [101/157] D_Loss: 0.016 G_Loss: 6.285
|
| 58 |
+
2025-07-13 11:22:24,054 - INFO - Epoch [4/50] Batch [151/157] D_Loss: 0.011 G_Loss: 6.005
|
| 59 |
+
2025-07-13 11:22:24,333 - INFO - Epoch 4 - D_Loss: 0.019, G_Loss: 6.681, Time: 2.2s
|
| 60 |
+
2025-07-13 11:22:25,286 - INFO - Epoch [5/50] Batch [1/157] D_Loss: 0.013 G_Loss: 7.839
|
| 61 |
+
2025-07-13 11:22:25,602 - INFO - Epoch [5/50] Batch [51/157] D_Loss: 0.055 G_Loss: 5.665
|
| 62 |
+
2025-07-13 11:22:25,914 - INFO - Epoch [5/50] Batch [101/157] D_Loss: 0.131 G_Loss: 7.865
|
| 63 |
+
2025-07-13 11:22:26,231 - INFO - Epoch [5/50] Batch [151/157] D_Loss: 0.208 G_Loss: 4.971
|
| 64 |
+
2025-07-13 11:22:26,514 - INFO - Epoch 5 - D_Loss: 0.080, G_Loss: 6.832, Time: 2.2s
|
| 65 |
+
2025-07-13 11:22:27,479 - INFO - Epoch [6/50] Batch [1/157] D_Loss: 0.059 G_Loss: 5.910
|
| 66 |
+
2025-07-13 11:22:27,797 - INFO - Epoch [6/50] Batch [51/157] D_Loss: 0.327 G_Loss: 5.019
|
| 67 |
+
2025-07-13 11:22:28,110 - INFO - Epoch [6/50] Batch [101/157] D_Loss: 0.069 G_Loss: 7.908
|
| 68 |
+
2025-07-13 11:22:28,422 - INFO - Epoch [6/50] Batch [151/157] D_Loss: 0.041 G_Loss: 7.707
|
| 69 |
+
2025-07-13 11:22:28,705 - INFO - Epoch 6 - D_Loss: 0.125, G_Loss: 7.011, Time: 2.2s
|
| 70 |
+
2025-07-13 11:22:29,668 - INFO - Epoch [7/50] Batch [1/157] D_Loss: 0.094 G_Loss: 9.911
|
| 71 |
+
2025-07-13 11:22:29,985 - INFO - Epoch [7/50] Batch [51/157] D_Loss: 0.099 G_Loss: 7.200
|
| 72 |
+
2025-07-13 11:22:30,294 - INFO - Epoch [7/50] Batch [101/157] D_Loss: 0.106 G_Loss: 6.806
|
| 73 |
+
2025-07-13 11:22:30,604 - INFO - Epoch [7/50] Batch [151/157] D_Loss: 0.072 G_Loss: 8.220
|
| 74 |
+
2025-07-13 11:22:30,884 - INFO - Epoch 7 - D_Loss: 0.160, G_Loss: 7.298, Time: 2.2s
|
| 75 |
+
2025-07-13 11:22:31,835 - INFO - Epoch [8/50] Batch [1/157] D_Loss: 0.127 G_Loss: 7.432
|
| 76 |
+
2025-07-13 11:22:32,158 - INFO - Epoch [8/50] Batch [51/157] D_Loss: 0.182 G_Loss: 7.185
|
| 77 |
+
2025-07-13 11:22:32,503 - INFO - Epoch [8/50] Batch [101/157] D_Loss: 0.324 G_Loss: 4.899
|
| 78 |
+
2025-07-13 11:22:32,816 - INFO - Epoch [8/50] Batch [151/157] D_Loss: 0.448 G_Loss: 5.160
|
| 79 |
+
2025-07-13 11:22:33,117 - INFO - Epoch 8 - D_Loss: 0.254, G_Loss: 6.831, Time: 2.2s
|
| 80 |
+
2025-07-13 11:22:34,086 - INFO - Epoch [9/50] Batch [1/157] D_Loss: 0.496 G_Loss: 4.999
|
| 81 |
+
2025-07-13 11:22:34,405 - INFO - Epoch [9/50] Batch [51/157] D_Loss: 0.343 G_Loss: 5.772
|
| 82 |
+
2025-07-13 11:22:34,719 - INFO - Epoch [9/50] Batch [101/157] D_Loss: 0.256 G_Loss: 4.703
|
| 83 |
+
2025-07-13 11:22:35,030 - INFO - Epoch [9/50] Batch [151/157] D_Loss: 0.150 G_Loss: 6.448
|
| 84 |
+
2025-07-13 11:22:35,309 - INFO - Epoch 9 - D_Loss: 0.330, G_Loss: 5.221, Time: 2.2s
|
| 85 |
+
2025-07-13 11:22:36,308 - INFO - Epoch [10/50] Batch [1/157] D_Loss: 0.299 G_Loss: 8.258
|
| 86 |
+
2025-07-13 11:22:36,653 - INFO - Epoch [10/50] Batch [51/157] D_Loss: 0.249 G_Loss: 5.360
|
| 87 |
+
2025-07-13 11:22:36,972 - INFO - Epoch [10/50] Batch [101/157] D_Loss: 0.340 G_Loss: 4.701
|
| 88 |
+
2025-07-13 11:22:37,305 - INFO - Epoch [10/50] Batch [151/157] D_Loss: 0.095 G_Loss: 6.552
|
| 89 |
+
2025-07-13 11:22:37,599 - INFO - Epoch 10 - D_Loss: 0.267, G_Loss: 5.786, Time: 2.3s
|
| 90 |
+
2025-07-13 11:22:38,595 - INFO - Epoch [11/50] Batch [1/157] D_Loss: 0.123 G_Loss: 8.758
|
| 91 |
+
2025-07-13 11:22:38,928 - INFO - Epoch [11/50] Batch [51/157] D_Loss: 0.231 G_Loss: 4.707
|
| 92 |
+
2025-07-13 11:22:39,252 - INFO - Epoch [11/50] Batch [101/157] D_Loss: 0.213 G_Loss: 6.000
|
| 93 |
+
2025-07-13 11:22:39,577 - INFO - Epoch [11/50] Batch [151/157] D_Loss: 0.315 G_Loss: 5.685
|
| 94 |
+
2025-07-13 11:22:39,862 - INFO - Epoch 11 - D_Loss: 0.252, G_Loss: 5.776, Time: 2.3s
|
| 95 |
+
2025-07-13 11:22:40,887 - INFO - Epoch [12/50] Batch [1/157] D_Loss: 0.267 G_Loss: 4.521
|
| 96 |
+
2025-07-13 11:22:41,220 - INFO - Epoch [12/50] Batch [51/157] D_Loss: 0.164 G_Loss: 6.560
|
| 97 |
+
2025-07-13 11:22:41,538 - INFO - Epoch [12/50] Batch [101/157] D_Loss: 0.360 G_Loss: 4.705
|
| 98 |
+
2025-07-13 11:22:41,864 - INFO - Epoch [12/50] Batch [151/157] D_Loss: 0.204 G_Loss: 5.475
|
| 99 |
+
2025-07-13 11:22:42,163 - INFO - Epoch 12 - D_Loss: 0.240, G_Loss: 5.424, Time: 2.2s
|
| 100 |
+
2025-07-13 11:22:43,122 - INFO - Epoch [13/50] Batch [1/157] D_Loss: 0.163 G_Loss: 6.708
|
| 101 |
+
2025-07-13 11:22:43,441 - INFO - Epoch [13/50] Batch [51/157] D_Loss: 0.314 G_Loss: 4.626
|
| 102 |
+
2025-07-13 11:22:43,773 - INFO - Epoch [13/50] Batch [101/157] D_Loss: 0.132 G_Loss: 6.173
|
| 103 |
+
2025-07-13 11:22:44,085 - INFO - Epoch [13/50] Batch [151/157] D_Loss: 0.378 G_Loss: 4.652
|
| 104 |
+
2025-07-13 11:22:44,373 - INFO - Epoch 13 - D_Loss: 0.230, G_Loss: 5.482, Time: 2.2s
|
| 105 |
+
2025-07-13 11:22:45,336 - INFO - Epoch [14/50] Batch [1/157] D_Loss: 0.259 G_Loss: 5.078
|
| 106 |
+
2025-07-13 11:22:45,655 - INFO - Epoch [14/50] Batch [51/157] D_Loss: 0.147 G_Loss: 5.611
|
| 107 |
+
2025-07-13 11:22:45,968 - INFO - Epoch [14/50] Batch [101/157] D_Loss: 0.212 G_Loss: 4.202
|
| 108 |
+
2025-07-13 11:22:46,279 - INFO - Epoch [14/50] Batch [151/157] D_Loss: 0.119 G_Loss: 7.232
|
| 109 |
+
2025-07-13 11:22:46,561 - INFO - Epoch 14 - D_Loss: 0.238, G_Loss: 5.009, Time: 2.2s
|
| 110 |
+
2025-07-13 11:22:47,526 - INFO - Epoch [15/50] Batch [1/157] D_Loss: 0.522 G_Loss: 7.273
|
| 111 |
+
2025-07-13 11:22:47,841 - INFO - Epoch [15/50] Batch [51/157] D_Loss: 0.183 G_Loss: 4.704
|
| 112 |
+
2025-07-13 11:22:48,154 - INFO - Epoch [15/50] Batch [101/157] D_Loss: 0.415 G_Loss: 3.363
|
| 113 |
+
2025-07-13 11:22:48,467 - INFO - Epoch [15/50] Batch [151/157] D_Loss: 0.218 G_Loss: 4.362
|
| 114 |
+
2025-07-13 11:22:48,746 - INFO - Epoch 15 - D_Loss: 0.244, G_Loss: 4.437, Time: 2.2s
|
| 115 |
+
2025-07-13 11:22:49,726 - INFO - Epoch [16/50] Batch [1/157] D_Loss: 0.514 G_Loss: 3.931
|
| 116 |
+
2025-07-13 11:22:50,044 - INFO - Epoch [16/50] Batch [51/157] D_Loss: 0.189 G_Loss: 5.084
|
| 117 |
+
2025-07-13 11:22:50,360 - INFO - Epoch [16/50] Batch [101/157] D_Loss: 0.212 G_Loss: 4.539
|
| 118 |
+
2025-07-13 11:22:50,677 - INFO - Epoch [16/50] Batch [151/157] D_Loss: 0.151 G_Loss: 4.327
|
| 119 |
+
2025-07-13 11:22:50,966 - INFO - Epoch 16 - D_Loss: 0.242, G_Loss: 4.478, Time: 2.2s
|
| 120 |
+
2025-07-13 11:22:51,921 - INFO - Epoch [17/50] Batch [1/157] D_Loss: 0.183 G_Loss: 5.415
|
| 121 |
+
2025-07-13 11:22:52,240 - INFO - Epoch [17/50] Batch [51/157] D_Loss: 0.397 G_Loss: 7.084
|
| 122 |
+
2025-07-13 11:22:52,554 - INFO - Epoch [17/50] Batch [101/157] D_Loss: 0.333 G_Loss: 3.645
|
| 123 |
+
2025-07-13 11:22:52,868 - INFO - Epoch [17/50] Batch [151/157] D_Loss: 0.181 G_Loss: 5.427
|
| 124 |
+
2025-07-13 11:22:53,153 - INFO - Epoch 17 - D_Loss: 0.220, G_Loss: 4.776, Time: 2.2s
|
| 125 |
+
2025-07-13 11:22:54,127 - INFO - Epoch [18/50] Batch [1/157] D_Loss: 0.107 G_Loss: 5.884
|
| 126 |
+
2025-07-13 11:22:54,444 - INFO - Epoch [18/50] Batch [51/157] D_Loss: 0.216 G_Loss: 4.467
|
| 127 |
+
2025-07-13 11:22:54,755 - INFO - Epoch [18/50] Batch [101/157] D_Loss: 0.212 G_Loss: 5.575
|
| 128 |
+
2025-07-13 11:22:55,075 - INFO - Epoch [18/50] Batch [151/157] D_Loss: 0.205 G_Loss: 3.849
|
| 129 |
+
2025-07-13 11:22:55,378 - INFO - Epoch 18 - D_Loss: 0.229, G_Loss: 4.560, Time: 2.2s
|
| 130 |
+
2025-07-13 11:22:56,348 - INFO - Epoch [19/50] Batch [1/157] D_Loss: 0.166 G_Loss: 4.697
|
| 131 |
+
2025-07-13 11:22:56,670 - INFO - Epoch [19/50] Batch [51/157] D_Loss: 0.530 G_Loss: 3.344
|
| 132 |
+
2025-07-13 11:22:56,992 - INFO - Epoch [19/50] Batch [101/157] D_Loss: 0.307 G_Loss: 5.135
|
| 133 |
+
2025-07-13 11:22:57,320 - INFO - Epoch [19/50] Batch [151/157] D_Loss: 0.153 G_Loss: 3.771
|
| 134 |
+
2025-07-13 11:22:57,602 - INFO - Epoch 19 - D_Loss: 0.249, G_Loss: 4.461, Time: 2.2s
|
| 135 |
+
2025-07-13 11:22:58,569 - INFO - Epoch [20/50] Batch [1/157] D_Loss: 0.382 G_Loss: 4.253
|
| 136 |
+
2025-07-13 11:22:58,886 - INFO - Epoch [20/50] Batch [51/157] D_Loss: 0.380 G_Loss: 3.176
|
| 137 |
+
2025-07-13 11:22:59,201 - INFO - Epoch [20/50] Batch [101/157] D_Loss: 0.239 G_Loss: 4.258
|
| 138 |
+
2025-07-13 11:22:59,529 - INFO - Epoch [20/50] Batch [151/157] D_Loss: 0.216 G_Loss: 5.879
|
| 139 |
+
2025-07-13 11:22:59,808 - INFO - Epoch 20 - D_Loss: 0.272, G_Loss: 4.471, Time: 2.2s
|
| 140 |
+
2025-07-13 11:23:00,782 - INFO - Epoch [21/50] Batch [1/157] D_Loss: 0.237 G_Loss: 6.417
|
| 141 |
+
2025-07-13 11:23:01,100 - INFO - Epoch [21/50] Batch [51/157] D_Loss: 0.330 G_Loss: 4.075
|
| 142 |
+
2025-07-13 11:23:01,422 - INFO - Epoch [21/50] Batch [101/157] D_Loss: 0.220 G_Loss: 5.957
|
| 143 |
+
2025-07-13 11:23:01,735 - INFO - Epoch [21/50] Batch [151/157] D_Loss: 0.061 G_Loss: 5.366
|
| 144 |
+
2025-07-13 11:23:02,014 - INFO - Epoch 21 - D_Loss: 0.209, G_Loss: 4.974, Time: 2.2s
|
| 145 |
+
2025-07-13 11:23:03,016 - INFO - Epoch [22/50] Batch [1/157] D_Loss: 0.125 G_Loss: 5.063
|
| 146 |
+
2025-07-13 11:23:03,330 - INFO - Epoch [22/50] Batch [51/157] D_Loss: 0.137 G_Loss: 5.944
|
| 147 |
+
2025-07-13 11:23:03,642 - INFO - Epoch [22/50] Batch [101/157] D_Loss: 0.156 G_Loss: 5.161
|
| 148 |
+
2025-07-13 11:23:03,953 - INFO - Epoch [22/50] Batch [151/157] D_Loss: 0.131 G_Loss: 6.399
|
| 149 |
+
2025-07-13 11:23:04,263 - INFO - Epoch 22 - D_Loss: 0.170, G_Loss: 5.673, Time: 2.2s
|
| 150 |
+
2025-07-13 11:23:05,263 - INFO - Epoch [23/50] Batch [1/157] D_Loss: 0.085 G_Loss: 6.612
|
| 151 |
+
2025-07-13 11:23:05,618 - INFO - Epoch [23/50] Batch [51/157] D_Loss: 0.198 G_Loss: 3.426
|
| 152 |
+
2025-07-13 11:23:05,956 - INFO - Epoch [23/50] Batch [101/157] D_Loss: 0.142 G_Loss: 5.337
|
| 153 |
+
2025-07-13 11:23:06,307 - INFO - Epoch [23/50] Batch [151/157] D_Loss: 0.283 G_Loss: 4.375
|
| 154 |
+
2025-07-13 11:23:06,595 - INFO - Epoch 23 - D_Loss: 0.243, G_Loss: 5.066, Time: 2.3s
|
| 155 |
+
2025-07-13 11:23:07,564 - INFO - Epoch [24/50] Batch [1/157] D_Loss: 0.246 G_Loss: 4.877
|
| 156 |
+
2025-07-13 11:23:07,879 - INFO - Epoch [24/50] Batch [51/157] D_Loss: 0.196 G_Loss: 3.591
|
| 157 |
+
2025-07-13 11:23:08,193 - INFO - Epoch [24/50] Batch [101/157] D_Loss: 0.164 G_Loss: 5.076
|
| 158 |
+
2025-07-13 11:23:08,506 - INFO - Epoch [24/50] Batch [151/157] D_Loss: 0.220 G_Loss: 5.017
|
| 159 |
+
2025-07-13 11:23:08,786 - INFO - Epoch 24 - D_Loss: 0.212, G_Loss: 5.454, Time: 2.2s
|
| 160 |
+
2025-07-13 11:23:09,735 - INFO - Epoch [25/50] Batch [1/157] D_Loss: 0.376 G_Loss: 4.019
|
| 161 |
+
2025-07-13 11:23:10,050 - INFO - Epoch [25/50] Batch [51/157] D_Loss: 0.268 G_Loss: 5.462
|
| 162 |
+
2025-07-13 11:23:10,361 - INFO - Epoch [25/50] Batch [101/157] D_Loss: 0.176 G_Loss: 7.060
|
| 163 |
+
2025-07-13 11:23:10,676 - INFO - Epoch [25/50] Batch [151/157] D_Loss: 0.318 G_Loss: 3.175
|
| 164 |
+
2025-07-13 11:23:10,955 - INFO - Epoch 25 - D_Loss: 0.269, G_Loss: 4.973, Time: 2.2s
|
| 165 |
+
2025-07-13 11:23:11,911 - INFO - Epoch [26/50] Batch [1/157] D_Loss: 0.259 G_Loss: 5.458
|
| 166 |
+
2025-07-13 11:23:12,224 - INFO - Epoch [26/50] Batch [51/157] D_Loss: 0.416 G_Loss: 4.406
|
| 167 |
+
2025-07-13 11:23:12,550 - INFO - Epoch [26/50] Batch [101/157] D_Loss: 0.185 G_Loss: 4.671
|
| 168 |
+
2025-07-13 11:23:12,919 - INFO - Epoch [26/50] Batch [151/157] D_Loss: 0.239 G_Loss: 5.871
|
| 169 |
+
2025-07-13 11:23:13,231 - INFO - Epoch 26 - D_Loss: 0.290, G_Loss: 4.670, Time: 2.3s
|
| 170 |
+
2025-07-13 11:23:14,247 - INFO - Epoch [27/50] Batch [1/157] D_Loss: 0.355 G_Loss: 5.252
|
| 171 |
+
2025-07-13 11:23:14,611 - INFO - Epoch [27/50] Batch [51/157] D_Loss: 0.354 G_Loss: 4.411
|
| 172 |
+
2025-07-13 11:23:15,011 - INFO - Epoch [27/50] Batch [101/157] D_Loss: 0.322 G_Loss: 5.771
|
| 173 |
+
2025-07-13 11:23:15,413 - INFO - Epoch [27/50] Batch [151/157] D_Loss: 0.497 G_Loss: 3.684
|
| 174 |
+
2025-07-13 11:23:15,724 - INFO - Epoch 27 - D_Loss: 0.342, G_Loss: 3.951, Time: 2.5s
|
| 175 |
+
2025-07-13 11:23:16,720 - INFO - Epoch [28/50] Batch [1/157] D_Loss: 0.169 G_Loss: 5.322
|
| 176 |
+
2025-07-13 11:23:17,095 - INFO - Epoch [28/50] Batch [51/157] D_Loss: 0.243 G_Loss: 5.145
|
| 177 |
+
2025-07-13 11:23:17,418 - INFO - Epoch [28/50] Batch [101/157] D_Loss: 0.291 G_Loss: 4.104
|
| 178 |
+
2025-07-13 11:23:17,731 - INFO - Epoch [28/50] Batch [151/157] D_Loss: 0.321 G_Loss: 4.954
|
| 179 |
+
2025-07-13 11:23:18,013 - INFO - Epoch 28 - D_Loss: 0.355, G_Loss: 3.937, Time: 2.3s
|
| 180 |
+
2025-07-13 11:23:18,976 - INFO - Epoch [29/50] Batch [1/157] D_Loss: 0.367 G_Loss: 3.584
|
| 181 |
+
2025-07-13 11:23:19,302 - INFO - Epoch [29/50] Batch [51/157] D_Loss: 0.571 G_Loss: 2.301
|
| 182 |
+
2025-07-13 11:23:19,625 - INFO - Epoch [29/50] Batch [101/157] D_Loss: 0.377 G_Loss: 3.155
|
| 183 |
+
2025-07-13 11:23:19,957 - INFO - Epoch [29/50] Batch [151/157] D_Loss: 0.408 G_Loss: 4.367
|
| 184 |
+
2025-07-13 11:23:20,239 - INFO - Epoch 29 - D_Loss: 0.388, G_Loss: 3.713, Time: 2.2s
|
| 185 |
+
2025-07-13 11:23:21,206 - INFO - Epoch [30/50] Batch [1/157] D_Loss: 0.328 G_Loss: 5.198
|
| 186 |
+
2025-07-13 11:23:21,527 - INFO - Epoch [30/50] Batch [51/157] D_Loss: 0.388 G_Loss: 4.180
|
| 187 |
+
2025-07-13 11:23:21,840 - INFO - Epoch [30/50] Batch [101/157] D_Loss: 0.284 G_Loss: 3.585
|
| 188 |
+
2025-07-13 11:23:22,155 - INFO - Epoch [30/50] Batch [151/157] D_Loss: 0.301 G_Loss: 4.791
|
| 189 |
+
2025-07-13 11:23:22,437 - INFO - Epoch 30 - D_Loss: 0.333, G_Loss: 4.205, Time: 2.2s
|
| 190 |
+
2025-07-13 11:23:23,391 - INFO - Epoch [31/50] Batch [1/157] D_Loss: 0.571 G_Loss: 5.715
|
| 191 |
+
2025-07-13 11:23:23,711 - INFO - Epoch [31/50] Batch [51/157] D_Loss: 0.334 G_Loss: 2.926
|
| 192 |
+
2025-07-13 11:23:24,036 - INFO - Epoch [31/50] Batch [101/157] D_Loss: 0.267 G_Loss: 3.822
|
| 193 |
+
2025-07-13 11:23:24,349 - INFO - Epoch [31/50] Batch [151/157] D_Loss: 0.307 G_Loss: 4.891
|
| 194 |
+
2025-07-13 11:23:24,633 - INFO - Epoch 31 - D_Loss: 0.351, G_Loss: 4.128, Time: 2.2s
|
| 195 |
+
2025-07-13 11:23:25,636 - INFO - Epoch [32/50] Batch [1/157] D_Loss: 0.423 G_Loss: 3.483
|
| 196 |
+
2025-07-13 11:23:25,953 - INFO - Epoch [32/50] Batch [51/157] D_Loss: 0.502 G_Loss: 4.788
|
| 197 |
+
2025-07-13 11:23:26,272 - INFO - Epoch [32/50] Batch [101/157] D_Loss: 0.248 G_Loss: 3.862
|
| 198 |
+
2025-07-13 11:23:26,587 - INFO - Epoch [32/50] Batch [151/157] D_Loss: 0.297 G_Loss: 3.970
|
| 199 |
+
2025-07-13 11:23:26,868 - INFO - Epoch 32 - D_Loss: 0.328, G_Loss: 4.403, Time: 2.2s
|
| 200 |
+
2025-07-13 11:23:27,829 - INFO - Epoch [33/50] Batch [1/157] D_Loss: 0.348 G_Loss: 5.138
|
| 201 |
+
2025-07-13 11:23:28,144 - INFO - Epoch [33/50] Batch [51/157] D_Loss: 0.211 G_Loss: 4.601
|
| 202 |
+
2025-07-13 11:23:28,457 - INFO - Epoch [33/50] Batch [101/157] D_Loss: 0.236 G_Loss: 5.468
|
| 203 |
+
2025-07-13 11:23:28,771 - INFO - Epoch [33/50] Batch [151/157] D_Loss: 0.325 G_Loss: 4.500
|
| 204 |
+
2025-07-13 11:23:29,050 - INFO - Epoch 33 - D_Loss: 0.311, G_Loss: 4.536, Time: 2.2s
|
| 205 |
+
2025-07-13 11:23:30,015 - INFO - Epoch [34/50] Batch [1/157] D_Loss: 0.383 G_Loss: 4.953
|
| 206 |
+
2025-07-13 11:23:30,329 - INFO - Epoch [34/50] Batch [51/157] D_Loss: 0.253 G_Loss: 4.417
|
| 207 |
+
2025-07-13 11:23:30,641 - INFO - Epoch [34/50] Batch [101/157] D_Loss: 0.426 G_Loss: 3.786
|
| 208 |
+
2025-07-13 11:23:30,954 - INFO - Epoch [34/50] Batch [151/157] D_Loss: 0.419 G_Loss: 3.220
|
| 209 |
+
2025-07-13 11:23:31,232 - INFO - Epoch 34 - D_Loss: 0.341, G_Loss: 4.485, Time: 2.2s
|
| 210 |
+
2025-07-13 11:23:32,203 - INFO - Epoch [35/50] Batch [1/157] D_Loss: 0.517 G_Loss: 2.477
|
| 211 |
+
2025-07-13 11:23:32,519 - INFO - Epoch [35/50] Batch [51/157] D_Loss: 0.407 G_Loss: 2.256
|
| 212 |
+
2025-07-13 11:23:32,833 - INFO - Epoch [35/50] Batch [101/157] D_Loss: 0.437 G_Loss: 3.213
|
| 213 |
+
2025-07-13 11:23:33,145 - INFO - Epoch [35/50] Batch [151/157] D_Loss: 0.509 G_Loss: 2.451
|
| 214 |
+
2025-07-13 11:23:33,422 - INFO - Epoch 35 - D_Loss: 0.442, G_Loss: 3.479, Time: 2.2s
|
| 215 |
+
2025-07-13 11:23:34,375 - INFO - Epoch [36/50] Batch [1/157] D_Loss: 0.686 G_Loss: 2.102
|
| 216 |
+
2025-07-13 11:23:34,692 - INFO - Epoch [36/50] Batch [51/157] D_Loss: 0.358 G_Loss: 4.190
|
| 217 |
+
2025-07-13 11:23:35,005 - INFO - Epoch [36/50] Batch [101/157] D_Loss: 0.343 G_Loss: 3.795
|
| 218 |
+
2025-07-13 11:23:35,317 - INFO - Epoch [36/50] Batch [151/157] D_Loss: 0.439 G_Loss: 2.760
|
| 219 |
+
2025-07-13 11:23:35,595 - INFO - Epoch 36 - D_Loss: 0.439, G_Loss: 3.209, Time: 2.2s
|
| 220 |
+
2025-07-13 11:23:36,555 - INFO - Epoch [37/50] Batch [1/157] D_Loss: 0.443 G_Loss: 2.539
|
| 221 |
+
2025-07-13 11:23:36,871 - INFO - Epoch [37/50] Batch [51/157] D_Loss: 0.595 G_Loss: 2.278
|
| 222 |
+
2025-07-13 11:23:37,183 - INFO - Epoch [37/50] Batch [101/157] D_Loss: 0.492 G_Loss: 3.511
|
| 223 |
+
2025-07-13 11:23:37,495 - INFO - Epoch [37/50] Batch [151/157] D_Loss: 0.374 G_Loss: 2.574
|
| 224 |
+
2025-07-13 11:23:37,775 - INFO - Epoch 37 - D_Loss: 0.443, G_Loss: 3.252, Time: 2.2s
|
| 225 |
+
2025-07-13 11:23:38,745 - INFO - Epoch [38/50] Batch [1/157] D_Loss: 0.327 G_Loss: 2.378
|
| 226 |
+
2025-07-13 11:23:39,061 - INFO - Epoch [38/50] Batch [51/157] D_Loss: 0.474 G_Loss: 2.944
|
| 227 |
+
2025-07-13 11:23:39,374 - INFO - Epoch [38/50] Batch [101/157] D_Loss: 0.268 G_Loss: 3.171
|
| 228 |
+
2025-07-13 11:23:39,685 - INFO - Epoch [38/50] Batch [151/157] D_Loss: 0.497 G_Loss: 2.537
|
| 229 |
+
2025-07-13 11:23:39,964 - INFO - Epoch 38 - D_Loss: 0.447, G_Loss: 3.178, Time: 2.2s
|
| 230 |
+
2025-07-13 11:23:40,915 - INFO - Epoch [39/50] Batch [1/157] D_Loss: 0.484 G_Loss: 2.305
|
| 231 |
+
2025-07-13 11:23:41,243 - INFO - Epoch [39/50] Batch [51/157] D_Loss: 0.554 G_Loss: 2.446
|
| 232 |
+
2025-07-13 11:23:41,556 - INFO - Epoch [39/50] Batch [101/157] D_Loss: 0.564 G_Loss: 3.132
|
| 233 |
+
2025-07-13 11:23:41,868 - INFO - Epoch [39/50] Batch [151/157] D_Loss: 0.445 G_Loss: 3.345
|
| 234 |
+
2025-07-13 11:23:42,147 - INFO - Epoch 39 - D_Loss: 0.446, G_Loss: 3.142, Time: 2.2s
|
| 235 |
+
2025-07-13 11:23:43,110 - INFO - Epoch [40/50] Batch [1/157] D_Loss: 0.472 G_Loss: 2.334
|
| 236 |
+
2025-07-13 11:23:43,426 - INFO - Epoch [40/50] Batch [51/157] D_Loss: 0.500 G_Loss: 2.421
|
| 237 |
+
2025-07-13 11:23:43,739 - INFO - Epoch [40/50] Batch [101/157] D_Loss: 0.437 G_Loss: 3.359
|
| 238 |
+
2025-07-13 11:23:44,051 - INFO - Epoch [40/50] Batch [151/157] D_Loss: 0.531 G_Loss: 3.274
|
| 239 |
+
2025-07-13 11:23:44,331 - INFO - Epoch 40 - D_Loss: 0.428, G_Loss: 3.358, Time: 2.2s
|
| 240 |
+
2025-07-13 11:23:45,288 - INFO - Epoch [41/50] Batch [1/157] D_Loss: 0.536 G_Loss: 3.828
|
| 241 |
+
2025-07-13 11:23:45,604 - INFO - Epoch [41/50] Batch [51/157] D_Loss: 0.369 G_Loss: 3.995
|
| 242 |
+
2025-07-13 11:23:45,917 - INFO - Epoch [41/50] Batch [101/157] D_Loss: 0.412 G_Loss: 2.651
|
| 243 |
+
2025-07-13 11:23:46,230 - INFO - Epoch [41/50] Batch [151/157] D_Loss: 0.381 G_Loss: 4.241
|
| 244 |
+
2025-07-13 11:23:46,509 - INFO - Epoch 41 - D_Loss: 0.474, G_Loss: 3.121, Time: 2.2s
|
| 245 |
+
2025-07-13 11:23:47,491 - INFO - Epoch [42/50] Batch [1/157] D_Loss: 0.312 G_Loss: 3.891
|
| 246 |
+
2025-07-13 11:23:47,806 - INFO - Epoch [42/50] Batch [51/157] D_Loss: 0.189 G_Loss: 4.416
|
| 247 |
+
2025-07-13 11:23:48,119 - INFO - Epoch [42/50] Batch [101/157] D_Loss: 0.594 G_Loss: 2.705
|
| 248 |
+
2025-07-13 11:23:48,432 - INFO - Epoch [42/50] Batch [151/157] D_Loss: 0.336 G_Loss: 3.526
|
| 249 |
+
2025-07-13 11:23:48,710 - INFO - Epoch 42 - D_Loss: 0.449, G_Loss: 3.213, Time: 2.1s
|
| 250 |
+
2025-07-13 11:23:49,673 - INFO - Epoch [43/50] Batch [1/157] D_Loss: 0.465 G_Loss: 4.197
|
| 251 |
+
2025-07-13 11:23:49,990 - INFO - Epoch [43/50] Batch [51/157] D_Loss: 0.288 G_Loss: 3.148
|
| 252 |
+
2025-07-13 11:23:50,301 - INFO - Epoch [43/50] Batch [101/157] D_Loss: 0.571 G_Loss: 1.964
|
| 253 |
+
2025-07-13 11:23:50,612 - INFO - Epoch [43/50] Batch [151/157] D_Loss: 0.386 G_Loss: 4.316
|
| 254 |
+
2025-07-13 11:23:50,892 - INFO - Epoch 43 - D_Loss: 0.452, G_Loss: 3.185, Time: 2.2s
|
| 255 |
+
2025-07-13 11:23:51,855 - INFO - Epoch [44/50] Batch [1/157] D_Loss: 0.575 G_Loss: 4.070
|
| 256 |
+
2025-07-13 11:23:52,171 - INFO - Epoch [44/50] Batch [51/157] D_Loss: 0.508 G_Loss: 3.639
|
| 257 |
+
2025-07-13 11:23:52,484 - INFO - Epoch [44/50] Batch [101/157] D_Loss: 0.321 G_Loss: 4.893
|
| 258 |
+
2025-07-13 11:23:52,795 - INFO - Epoch [44/50] Batch [151/157] D_Loss: 0.369 G_Loss: 2.931
|
| 259 |
+
2025-07-13 11:23:53,075 - INFO - Epoch 44 - D_Loss: 0.446, G_Loss: 3.338, Time: 2.2s
|
| 260 |
+
2025-07-13 11:23:54,018 - INFO - Epoch [45/50] Batch [1/157] D_Loss: 0.476 G_Loss: 3.702
|
| 261 |
+
2025-07-13 11:23:54,334 - INFO - Epoch [45/50] Batch [51/157] D_Loss: 0.416 G_Loss: 3.484
|
| 262 |
+
2025-07-13 11:23:54,646 - INFO - Epoch [45/50] Batch [101/157] D_Loss: 0.500 G_Loss: 3.784
|
| 263 |
+
2025-07-13 11:23:54,957 - INFO - Epoch [45/50] Batch [151/157] D_Loss: 0.517 G_Loss: 3.381
|
| 264 |
+
2025-07-13 11:23:55,235 - INFO - Epoch 45 - D_Loss: 0.458, G_Loss: 3.254, Time: 2.2s
|
| 265 |
+
2025-07-13 11:23:56,193 - INFO - Epoch [46/50] Batch [1/157] D_Loss: 0.452 G_Loss: 2.595
|
| 266 |
+
2025-07-13 11:23:56,523 - INFO - Epoch [46/50] Batch [51/157] D_Loss: 0.549 G_Loss: 2.774
|
| 267 |
+
2025-07-13 11:23:56,838 - INFO - Epoch [46/50] Batch [101/157] D_Loss: 0.455 G_Loss: 2.451
|
| 268 |
+
2025-07-13 11:23:57,152 - INFO - Epoch [46/50] Batch [151/157] D_Loss: 0.312 G_Loss: 3.342
|
| 269 |
+
2025-07-13 11:23:57,430 - INFO - Epoch 46 - D_Loss: 0.480, G_Loss: 3.068, Time: 2.2s
|
| 270 |
+
2025-07-13 11:23:58,387 - INFO - Epoch [47/50] Batch [1/157] D_Loss: 0.429 G_Loss: 3.185
|
| 271 |
+
2025-07-13 11:23:58,722 - INFO - Epoch [47/50] Batch [51/157] D_Loss: 0.573 G_Loss: 3.059
|
| 272 |
+
2025-07-13 11:23:59,038 - INFO - Epoch [47/50] Batch [101/157] D_Loss: 0.666 G_Loss: 2.839
|
| 273 |
+
2025-07-13 11:23:59,348 - INFO - Epoch [47/50] Batch [151/157] D_Loss: 0.418 G_Loss: 3.074
|
| 274 |
+
2025-07-13 11:23:59,643 - INFO - Epoch 47 - D_Loss: 0.516, G_Loss: 3.013, Time: 2.2s
|
| 275 |
+
2025-07-13 11:24:00,604 - INFO - Epoch [48/50] Batch [1/157] D_Loss: 0.447 G_Loss: 2.961
|
| 276 |
+
2025-07-13 11:24:00,924 - INFO - Epoch [48/50] Batch [51/157] D_Loss: 0.595 G_Loss: 3.247
|
| 277 |
+
2025-07-13 11:24:01,238 - INFO - Epoch [48/50] Batch [101/157] D_Loss: 0.449 G_Loss: 2.994
|
| 278 |
+
2025-07-13 11:24:01,545 - INFO - Epoch [48/50] Batch [151/157] D_Loss: 0.427 G_Loss: 3.454
|
| 279 |
+
2025-07-13 11:24:01,825 - INFO - Epoch 48 - D_Loss: 0.471, G_Loss: 3.184, Time: 2.2s
|
| 280 |
+
2025-07-13 11:24:02,833 - INFO - Epoch [49/50] Batch [1/157] D_Loss: 0.600 G_Loss: 3.144
|
| 281 |
+
2025-07-13 11:24:03,148 - INFO - Epoch [49/50] Batch [51/157] D_Loss: 0.230 G_Loss: 3.468
|
| 282 |
+
2025-07-13 11:24:03,460 - INFO - Epoch [49/50] Batch [101/157] D_Loss: 0.541 G_Loss: 3.467
|
| 283 |
+
2025-07-13 11:24:03,771 - INFO - Epoch [49/50] Batch [151/157] D_Loss: 0.451 G_Loss: 3.256
|
| 284 |
+
2025-07-13 11:24:04,048 - INFO - Epoch 49 - D_Loss: 0.445, G_Loss: 3.259, Time: 2.2s
|
| 285 |
+
2025-07-13 11:24:05,005 - INFO - Epoch [50/50] Batch [1/157] D_Loss: 0.424 G_Loss: 2.920
|
| 286 |
+
2025-07-13 11:24:05,322 - INFO - Epoch [50/50] Batch [51/157] D_Loss: 0.326 G_Loss: 4.424
|
| 287 |
+
2025-07-13 11:24:05,639 - INFO - Epoch [50/50] Batch [101/157] D_Loss: 0.404 G_Loss: 2.636
|
| 288 |
+
2025-07-13 11:24:05,956 - INFO - Epoch [50/50] Batch [151/157] D_Loss: 0.300 G_Loss: 4.418
|
| 289 |
+
2025-07-13 11:24:06,238 - INFO - Epoch 50 - D_Loss: 0.394, G_Loss: 3.880, Time: 2.2s
|
| 290 |
+
2025-07-13 11:24:06,238 - INFO - Total time: 113.3s (1.9 min)
|
| 291 |
+
2025-07-13 11:24:06,306 - INFO - Lite model saved!
|
gan_training_lite.log
ADDED
|
File without changes
|
generator_lite.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:64355acf3c01af075060b936ad3d8a1eafe007864c5822e146c38090f7d34dd4
|
| 3 |
+
size 2319317
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch>=2.0.0
|
| 2 |
+
torchvision>=0.15.0
|
| 3 |
+
numpy>=1.21.0
|
| 4 |
+
matplotlib>=3.5.0
|
| 5 |
+
jupyter>=1.0.0
|
| 6 |
+
notebook>=6.4.0
|