Portfolio: PBS – Neural Net for Hand Written Digits
In 2017, I was educating myself about ai and in the course of that journey, I wanted to get a much better understanding of how neural nets work (If you’d like a basic introduction to neural nets, you might enjoy my blog: What is a Neural Net anyway? )
I decided to set myself a ridiculous challenge of writing a neural net from scratch that could be configured, trained and used directly in the browser using no libraries. It was in the days before tensorflow.js and I also constrained myself not to look at anyone else’s code!
It took me a couple of months and once I’d made my neural net configurable and trainable so that it could solve the typical “hello world” problems in the data science world (xor, sine wave and similar for those interested) I decided to move up a gear and see if I could train it to interpret hand written digits. This is also a well known problem for novice data scientists to solve and if you are coding in python with numpy available, then you can do a pretty good job with less than 15 lines of code. No such luxury for me though!
You can see the application running in the window below as a series of hand drawn digits are presented to the neural net that I trained. The neural net crunches the data and draws its conclusion which is then displayed just below the image. There is a built in delay between each digit and you can use the slider below to speed it up and slow it downhttps:
I was truly amazed when I saw how quickly my home grown neural net could interpret the hand drawn digits and it proved to me that ai in the browser was truly possible without relying on a backend to do the heavy lifting.
The neural net I configured to handle this data has:
- 784 input nodes (one for each pixel in a 28 by 28 matrix)
- 100 hidden nodes (found by experimentation)
- 10 output nodes (one for each possible digit)
It means that for each character decoded, there is at least 79,400 calculations occurring (784*100 + 100*10).
As I write this in the last days of 2020, tensorflow.js is a serious tool that developers can use to achieve the same thing but even more performant and with a fully supported open source tool. Even so, I’d still recommend attempting this problem if you want a much deeper understanding of how neural nets work and how ai can achieve extraordinary things
This version of my solution is a cut down implementation and you can see the broader functionality that I built by using this github link.
If you’d like to learn to code or find out out to develop your skills needed for any of the wide variety of jobs available in the digital transformation world, please email or give us a call.
If you have some digital transformations that you need to make progress with then please let us know. Our team of developers are ready for action!
Peter Brookes-Smith
Curious problem solver, business developer, technologist and customer advocate
Other blogs by Peter
- Legacy Applications – How did we get here and what can we do?
- Needles and haystacks or…
- The Case of Rev. Bayes v The Post Office
- Lighting a fire – Our first annual review…
- Helping Mine Detectors learn to use their equipment correctly
- How many?
- Finding defects with AI and computer vision
- CS50 – Harvard’s Open Computer Science Course
- What is a neural net anyway?
- Values Driven Business
- All things come to those that wait…
- Monte Carlo or Bust!
- What is business agility? And why should I care?
- Are values in business our fair weather friend?
- Lessons in life from an ai agent
- Five tools for innovation mastery
- Value for money
- Award entry for European CEO Magazine 2017
- Darwin and The Travelling Salesperson
- What is this DevOps thing?
Blogs by other authors:
- From Stubble to Squad Goals: Our Mo-numental Mo-vember Mo-arvel!
- Learning a Foreign Language vs. Learning to Code: What’s the Difference?
- Solving complex problems through code – and nature!
- In it together – why employee ownership is right for us
- Old Dogs and New Tricks: The Monte Carlo Forecasting Journey
- Portfolio: Rachel – Photo Editing
- Portfolio: Luke – Hangman
- Portfolio: Will – Gym Machines