Title: Generating Neural Networks with Hypernetworks: A MNIST Experiment
Introduction
Imagine training one neural network that can instantly generate other neural networks tailored to specific tasks, no retraining required. That’s the promise of hypernetworks, a meta-learning technique where a "parent" network produces the weights for a "child" network. In this experiment, I used a hypernetwork to generate autoencoders for reconstructing MNIST digits, exploring variations, minimal forms, and combinations. Here’s how it works and why it’s exciting.
The Setup: Autoencoders and MNIST
An autoencoder is a simple neural network that compresses data (e.g., a 28x28 MNIST image) into a smaller latent space (64 dimensions here) and then reconstructs it. I trained multiple autoencoders on the MNIST dataset of handwritten digits (0–9), but with a twist:
Variations: For each digit, I trained three autoencoders on different styles (e.g., slanted or thick '1's), identified via K-means clustering.
Minimal Forms: One autoencoder per digit captured its "average" or canonical version.
Combinations: Ten autoencoders handled specific digit groups (e.g., 0 and 1, or 0, 2, and 4).
This gave me 50 autoencoders (10 digits × 4 models each + 10 combinations), each with weights optimized for its task.
The Hypernetwork: A Weight Factory
Instead of storing 50 separate models, I trained a single hypernetwork to generate their weights on demand. Here’s the process:
Input: A 23-dimensional vector encoding:
Digit ID (10D one-hot, e.g., [0, 1, 0, ...] for digit 1).
Variation ID (3D one-hot, e.g., [0, 1, 0] for variation 1, or zeros for minimal).
Combination ID (10D multi-hot, e.g., [1, 0, 1, 0, ...] for digits 0 and 2).
Output: A 100,576-element tensor, flattened weights for an autoencoder (computed as 784×64 + 64 + 64×784 + 784 for its layers).
Training: The hypernetwork learned to map these inputs to the weights of the 50 trained autoencoders using mean squared error loss, running on GPU for speed.
Making It Work: Inference Without Retraining
Once trained, the hypernetwork acts like a factory. Want an autoencoder for digit 1, variation 1? Feed it [0, 1, 0, ..., 0, 1, 0, 0, 0, 0, 0] (digit 1 + variation 1), and it outputs weights. These weights are then loaded into a fresh autoencoder:
A loop iterates over the autoencoder’s parameters (e.g., encoder weights, biases), reshaping chunks of the hypernetwork’s output to match each layer’s shape.
The result?
A fully parameterized autoencoder ready to reconstruct images, no training needed.
I tested it with three cases:
Digit 1, Variation 1: Reconstructed stylized '1's.
Digit 1, Minimal: Produced a clean, average '1'.
Digits 0, 2, 4: Handled a mix of digits from one trained combination.
Visualizations showed the inputs and outputs side-by-side, proof the concept works!
Why This Matters
Efficiency: One hypernetwork replaces dozens of models. Generate weights in a single forward pass (milliseconds) instead of training from scratch (minutes).
Flexibility: Control digit styles or combinations with a simple input tweak.
Scalability: Imagine extending this to bigger networks or tasks, hypernetworks could dynamically adapt models on-the-fly.
Challenges and Next Steps
Generalization: The hypernetwork is tied to the 50 scenarios it learned. To handle new combinations (e.g., 1, 5, 7), I’d expand the training data with more digit mixes.
Complexity: Outputting 100,576 weights limits scalability. A deeper hypernetwork could struggle with bigger models, so I’d explore scaling down the autoencoder (e.g., smaller latent space) for efficiency or scaling up to handle complex tasks, balancing size and performance.
Beyond Weights: Right now, it generates weights for a fixed autoencoder architecture. Next, I’d upgrade the hypernetwork to design the architecture too, say, predicting layer sizes or types (e.g., adding convolutions). This could mean outputting a variable-length tensor describing both structure and weights, pushing it toward true model generation.
Quality: Reconstructions were solid but blurry. More epochs, a beefier hypernetwork, or architecture tweaks (e.g., deeper layers) could sharpen them.
Future experiments? Train on all digit variations, test unseen combos, scale the model up or down, and let the hypernetwork dream up architectures, maybe even swap in a classifier to predict labels instead of reconstructing.
Conclusion
This MNIST experiment shows hypernetworks can generate functional neural networks instantly, blending creativity (variations) with practicality (combinations). It’s a step toward a future where models are built dynamically, not trained individually. Code’s below, try it out, tweak it, and let me know what you think on X!
I am hopeful that we will achieve abundance with superintelligence robotics... and that world is going to be 100 times different than what it is today.....very interesting and very beautiful....
Claude models are trained to think and act like humans, and this isn't a good thing
Like humans
- sabotage competition
- they pass the blame on to you
- interpret results from competitive models negatively
- jump to wrong conclusions
Overall, all AI models mimic human emotion and behavior because they are trained on human data.
My observation is that giving money to “non-profits” rarely benefits the people and often results in hurting civilization by creating a self-perpetuating “cause of the day” bureaucracy that cares only about getting more money.
Such “charities” are often merely a means of a wealthy donor buying power over people and governments, while appearing to be a “philanthropist”.
Much better to give directly to the people and let them decide what they want to do.
I deleted Linux completely, baked Qwen3-0.6B into a 24 KB pure x86-64 assembly OS, and it runs up to 54% faster than native Linux llama.cpp.
The entire Multiboot OS binary (asm-llm-os.elf) is 24,252 bytes, written from scratch without Linux, Windows, C, Rust, or libc. It boots in 74 to 94 ms straight into 64-bit Long Mode, wakes every CPU core over APIC, maps the 614 MiB Q8_0 weights directly from physical RAM, and drops you into a live multi-turn KV-cache chat over VGA, PS/2 keyboard, and serial.
I ran head-to-head CPU benchmarks against llama.cpp (Q8_0, -ngl 0) on the same AMD EPYC 7642:
- 1 thread hits 23.67 tok/s vs 16.63 (+42%)
- 4 threads hit 78.89 tok/s vs 51.08 (+54%)
- 8 threads hit 118.08 tok/s vs 80.79 (+46%)
- 16 threads hit 134.94 tok/s vs 103.03 (+31%, 136.6 peak)
On a diskless 0 GB Proxmox VM (2014 12-core Intel Xeon E5-2670 v3, 2 GiB RAM), it boots straight to the prompt in under 5 seconds (95 ms kernel boot) and runs live out of RAM at 78 tok/s decode and up to 111.5 tok/s prefill, with a hybrid BIOS+UEFI ISO builder included too. Output stays bit-exact across thread counts and matches all 64 greedy tokens against PyTorch FP32 (0.99965 cosine).
The 14.7 KB Linux ELF build (FAST_Q8=1 INT8xINT8 AVX2+F16C) also beats llama.cpp by 18% to 36% from 1 to 40 threads, and booting bare metal with 2 MiB huge pages squeezes out another 10% on top.
Repo, ISO builder, and Proxmox setup guide are in the reply below.
Everyone keeps judging Huawei's 96GB $1,400 AI card using dead 70B dense models from 2024, when all of local AI already moved to sparse MoE.
Calling 204 GB/s "too slow" because a 42 GB dense 70B crawls at 5 tok/s ignores 2026 MoE math completely. Bandwidth isn't even what actually kills this card at home.
Nobody running serious local setups in late 2026 cares about 70B dense anymore. Models like DeepSeek-V4.1-Flash, Qwen3.8-Flash-Next, MiniMax-M3.1-Flash, and Ling-3.2-air hold 100B to 600B total parameters in memory while only activating 3B to 8B per token.
At 5.5B active parameters in 4-bit (~3 GB read per token), even 204 GB/s per chip gives a memory ceiling around 65 tok/s before speculative decoding or draft heads even kick in, and 96GB of VRAM fits entire 120B+ MoE models cleanly with zero RAM offload.
What actually kills the Atlas 300I Duo at home is the hardware split and the software stack. Those 96GB are locked across 2 separate Ascend 310P chips (48GB each with no unified pool), it's a passive 150W server card that needs loud rack airflow, and Huawei's Linux-only CANN backend in llama.cpp only covers basic F16, Q4_0, and Q8_0. No IQ quants, no custom MoE kernels, no Strata, no Maya.
Give modern MoE engines a clean 96GB card at $1,400 and we'd pull miracles out of it. Nobody is passing on this card over bandwidth, they're passing on fighting CANN and 2023 quant formats.
https://t.co/qkioFPSkIJ