Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

MiniFCNN

Neural network implementations from scratch in .NET 10 — no ML libraries. Built for learning: every weight, bias, forward pass, and backprop step is explicit in the code.


IrisSample

Task: Classify iris flowers into 3 species (setosa, versicolor, virginica) from 4 measurements (sepal/petal length and width).

Why Iris: 150 samples, 4 inputs, 3 classes — small enough to understand completely, real enough to be meaningful. The go-to first dataset for learning classification.

Architecture: Input(4) → Hidden(8, ReLU) → Hidden(4, ReLU) → Output(3, Softmax)

The two hidden layers are sufficient because the decision boundary between species, while non-linear, is not complex. Wider or deeper would overfit on 150 samples. The funnel shape (8→4) compresses learned features toward the 3 output classes.

Result: ~100% test accuracy in under 100 epochs. Iris is a clean dataset — the species are well-separated in feature space.


MnistSample

Task: Classify handwritten digits 0–9 from 28×28 grayscale images (70,000 samples total, 60k train / 10k test).

Why MNIST: The standard benchmark for image classification. Big enough to require real training time, simple enough that a plain FCNN can still do well.

Architecture: Input(784) → Hidden(128, ReLU) → Hidden(64, ReLU) → Output(10, Softmax)

Input is the image flattened to 784 pixel values (28×28). The 784→128 first layer is the bottleneck — wide enough to detect varied pixel patterns, not so wide it's wasteful. 128→64 compresses further before the 10-class output. No spatial awareness: the network treats pixels as independent values with no knowledge they form a 2D image.

Result: 97.9% test accuracy after 10 epochs (~2 min/epoch on CPU). The remaining ~2% errors are mostly genuinely ambiguous digits.


MnistCnnSample

Task: Same as MnistSample — digit classification on MNIST.

Why CNN: A Convolutional Neural Network preserves the 2D structure of the image. Instead of treating 784 pixels as independent inputs, convolutional layers slide small filters across the image and detect local patterns (edges, curves, strokes) at every position. This gives the network spatial awareness that a plain FCNN lacks.

Architecture:

Input (1×28×28)
→ Conv(8 filters, 3×3) → ReLU → MaxPool(2×2)    — 1×28×28 → 8×13×13
→ Conv(16 filters, 3×3) → ReLU → MaxPool(2×2)   — 8×13×13 → 16×5×5 = 400
→ FC(400→128) → ReLU
→ FC(128→10) → Softmax

The two conv layers learn increasingly abstract features: early filters detect edges and strokes, later filters combine those into digit-like shapes. MaxPool halves spatial dimensions after each conv layer — reduces computation and makes the network tolerant to small shifts in position. The final FC layers do the classification from the extracted features, same as in MnistSample.

Key difference from MnistSample: filter weights are shared across all positions in the image. A filter that detects a horizontal stroke works anywhere in the 28×28 grid — not just top-left. This is why CNNs need far fewer parameters than a pure FCNN for image tasks, yet outperform them.

Result: 98.3% test accuracy after 5 epochs (~5–8 min/epoch on CPU), peaking at 98.6% on epoch 3. Beats MnistSample from epoch 1 despite fewer total epochs.


Other Samples

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages