➡️ ML from scratch part 13: Training and building our own tiny image generator AI What we need…
MachineLearningToGo
Visit on TikTok29K followers
37,400 views #machinelearning #ai #imagegeneration
➡️ ML from scratch part 13: Training and building our own tiny image generator AI What we need: Python, numpy, a free library for fast math on big lists of numbers, and the 3,000 digits our code drew in part 10. Step 1, squeeze and paint. One small network squeezes all 256 pixels of a digit into just two numbers, a spot on a map. A second network paints 256 pixels back from two numbers, and that one is our image generator. Step 2, training. At first it only paints a grey fog. We train both networks on the 3,000 digits for 8,000 steps: squeeze, paint, compare with the real picture and send the error back. That is backpropagation and gradient descent from parts 8 and 9, with an Adam style step. The error per pixel falls from 0.281 to 0.028. Step 3, the map. Nobody tells the network which digit is which, and still 66 % of the digits land closest to the centre of their own kind. The zeros gather in one corner, the sevens along the right edge, and digits that look alike sit side by side. Step 4, a new digit. At the spot 0.29, −0.20 no training digit sits within 0.1, and the painting network draws a 2 there that is in none of the 3,000 pictures. Step 5, the walk. On a straight line from the zeros to the sevens, the picture melts from a 0 into a 3, then a 2, then a 7. The honest limit. With only two numbers the pictures stay a little blurry, and almost one in five of the fives comes back looking like a six. The same code with 16 numbers paints much sharper digits. Real generators like Stable Diffusion work in a far bigger space of numbers, start from random noise and let your prompt steer every step. The core idea is the same: numbers in, pixels out. At the end we run the finished generator: it learns for about 30 seconds (sped up here), one extra print line shows the new 2 as text in the terminal. Every digit here was painted by the real trained network. #machinelearning #ai #imagegeneration #coding #python
Comments
Comments from the original post on TikTok
No comments yet
