I'm proud to announce a demo showing that neural networks can run and even do useful work on TI graphing calculators. With this project, you can train a 4-layer convolutional neural network (CNN) to identify handwritten digits, directly on a TI-84 Plus CE calculator. You can test it on samples from the MNIST handwritten digit dataset, or connect a USB mouse and draw digits for it to identify.
I've seen a number of projects that bring "AI" to graphing calculators, all using a TI-84 Plus CE as a dumb terminal for the ChatGPT API. One used the ESP32 wireless microcontroller board, with a 240MHz CPU, to communicate with the ChatGPT API, while others have used a simpler USB serial connection. One project was even subverted by a cryptobro "entrepreneur" to claim he created an LLM so efficient, it could run on a calculator. But none of these projects was actually running any kind of intelligence on the calculator itself, not even the simplest single-layer neural network. Calculators aren't particularly powerful, but they are as capable of performing the math using in machine learning as any other general-purpose CPU, so I set out to make a calculator run a neural network - and do something useful with it.
Over March 25-27, 2023, I took the Amtrak California Zephyr from San Francisco all the way to Chicago, a 56-hour journey during which I challenged myself to complete this project. These three days (details on my blog) encompassed tasks like:
At the end of that train trip, I had a program that could train and run a convolutional neural network on the MNIST handwritten digit dataset to identify digits directly on the calculator. Although the calculator can run both training and inference, at its current speed it would require 1316 hours (55 days) to train on all the images in the dataset, or even 76 hours for the 3,486 samples that could fit in the calculator’s Flash memory. Therefore, it was prudent to train the network on a computer (requiring less than 5 minutes), transfer the checkpointed network state, and run inference on the calculator: inference takes around 18 seconds. The trained network achieves better than 95% accuracy, and qualitatively, its predictions make sense.
Shortly after I returned, I added USB mouse support, and with the finished product, you can draw a digit with the mouse, and in 18 seconds, the program will identify which digit you drew. Potential future work includes accelerating the program through the use of better-optimized software floats or fixed-point numbers, and provide higher accuracy through the use of quantized weights and values. As a coda to this project, I'd like to make my own version of simply tethering a calculator to an LLM like ChatGPT, as I think there are more useful features it could facilitate than simply holding a conversation with it.
- Detailed writeup: https://z80.me/blog/calculator-ai-part-1/
- Video: https://youtu.be/olcZdTRdnQg
I've seen a number of projects that bring "AI" to graphing calculators, all using a TI-84 Plus CE as a dumb terminal for the ChatGPT API. One used the ESP32 wireless microcontroller board, with a 240MHz CPU, to communicate with the ChatGPT API, while others have used a simpler USB serial connection. One project was even subverted by a cryptobro "entrepreneur" to claim he created an LLM so efficient, it could run on a calculator. But none of these projects was actually running any kind of intelligence on the calculator itself, not even the simplest single-layer neural network. Calculators aren't particularly powerful, but they are as capable of performing the math using in machine learning as any other general-purpose CPU, so I set out to make a calculator run a neural network - and do something useful with it.
Over March 25-27, 2023, I took the Amtrak California Zephyr from San Francisco all the way to Chicago, a 56-hour journey during which I challenged myself to complete this project. These three days (details on my blog) encompassed tasks like:
- Building a Python tool to pack the 70,000 sample images from the MNIST dataset into AppVars
- Porting the components of a very simple C neural network framework to the TI-84 Plus CE
- Making my fledgling program compile and run on both PC and calculator
- Building a new memory allocator
- Overhauling the neural network framework I had ported to support checkpointing
- Much testing and debugging
At the end of that train trip, I had a program that could train and run a convolutional neural network on the MNIST handwritten digit dataset to identify digits directly on the calculator. Although the calculator can run both training and inference, at its current speed it would require 1316 hours (55 days) to train on all the images in the dataset, or even 76 hours for the 3,486 samples that could fit in the calculator’s Flash memory. Therefore, it was prudent to train the network on a computer (requiring less than 5 minutes), transfer the checkpointed network state, and run inference on the calculator: inference takes around 18 seconds. The trained network achieves better than 95% accuracy, and qualitatively, its predictions make sense.
Shortly after I returned, I added USB mouse support, and with the finished product, you can draw a digit with the mouse, and in 18 seconds, the program will identify which digit you drew. Potential future work includes accelerating the program through the use of better-optimized software floats or fixed-point numbers, and provide higher accuracy through the use of quantized weights and values. As a coda to this project, I'd like to make my own version of simply tethering a calculator to an LLM like ChatGPT, as I think there are more useful features it could facilitate than simply holding a conversation with it.