Skip to content
Xila

Digits

Understand how Digits recognizes handwritten digits through a neural-network device.

Last updatedEdit page

Digits recognizes handwritten digits. It runs as a guest application named xila-digits in the Applications repository.

Digits depends on the drawing representation of Pixel Painter and a neural-network device. See Guest applications for how the bundle is packaged and launched. The native and browser image profiles include the bundle.

Digits crops the drawn ink and fits it into a 28 by 28 input. It embeds a TensorFlow Lite model. It opens /devices/nn/cpu for reading and writing. The native runtime registers a loader at that path.

The following sequence shows model loading and prediction.

Model loading and prediction on the neural-network deviceDigitsNeural-network device Open for reading and writingSeek to zero and write modelLOAD with LoadRequestQuery tensor information and countsSelect input, seek and write pixelsCOMPUTESelect output, seek and read scores

Digits writes the model to the device. It then sends device::neural_network::LOAD with a TensorFlow Lite LoadRequest. It checks the input and output tensors, writes the input, and sends device::neural_network::COMPUTE. It reads ten scores and ranks the three highest.

The embedded model travels with the guest. The neural-network device performs inference. The guest prepares the drawing and validates the returned probabilities.

Digits requires one float32 input shaped [1, 784] and one float32 output shaped [1, 10]. Empty drawings do not produce an input.