Loading video...
Video Failed to Load
Just for fun, I've implemented a Convolutional Neural Network (CNN) that predicts handwritten digits... Fully using #glsl and fragment shaders! The model exactly has 2023 parameters and its inner activations are displayed as you draw Try it out live!
118,358 views • 3 years ago •via X (Twitter)
9 Comments

Nice! To improve the recognition, you should randomly offset the training data. The NIST data is centered. If you offset the data the network learns to detect non-centered digits too.

Thanks! I did try data augmentation and had way better results in python, but when converting the model to glsl I decided to downscale it a lot to reduce compilation time (it started with 70x more parameters) and it became too small to handle augmented data

6 is a problem ;)

Indeed, this is the model’s weak spot! I had to make compromises between the model size and accuracy in order to make it work smoothly inside glsl shaders. 2023 trainable parameters is order of magnitudes lower than typical CNN implementations for this task!

@__jrm_filipe Niiice! For a reason I never get to have the 6 predicted

@__jrm_filipe Yes this is the weak spot of this very tiny model!

@mayfer The visualization is super sick

@mayfer Is reimplementing papers in shadertoy the best way to learn 🤔

@mayfer Not sure if it’s the best way ahah but it definitely made me understand more profoundly how CNNs work as I had to implement every step from scratch

