Machine learning is now being applied in many areas of everyday life. Unlike financial and scientific applications, which require significant computing power for machine learning to deliver results, internet of things (IoT) and edge-based applications have limited computing and connectivity resources available for this purpose. In this article, we explore how machine learning can be implemented using less complex and lower power microcontrollers, an approach commonly referred to as TinyML.
AI and Machine Learning: Now integrated into everyday life
While previously just the realm of science fiction, nowadays, it is common for people to give spoken instruction to smart speakers, automobile infotainment systems and smartphones. This has been made possible by developments in Artificial intelligence (AI), a science that enables computers to ‘think’, sense and provide solutions to problems that they recognize. Machine learning (ML) is an application of AI in which computers use algorithms to ‘learn’ and refine how they perform a task without the requirement to be pre-programmed.
Apart from scientific research, which relies on ML to analyse the trends hidden in Petabytes of stored data, ML is now a feature in many aspects of everyday life including long range weather forecasting, targeted advertising on social media apps and in route navigation.
Machine Learning in action
The way in which ML is applied in the applications previously considered is usually hidden – with only the results being made visible to the user. However, discovering new planets or tracking climate change requires huge volumes of data, the evaluation of several different algorithms and enormous levels of computing power. Machine learning can be broken down into sub-categories – supervised, unsupervised, semi-supervised, and reinforcement learning – each suited to performing different tasks.
Neural networks, which attempt to mathematically model the way in which the neurons in the human brain function, are a key component of an ML application. The algorithms used in the model can ‘infer’ the probability of a positive result occurring. For example, in an image recognition application it can help to determine the probability that a picture contains an apple. Convolutional neural networks (CNN) and recurrent neural networks (RNN) are types of neural networks that use different numbers of layers depending on the type of problem being solved.
For the algorithms used by neural networks to be able perform a task, a large volume of training data is required in a process called supervised learning. A CNN is the best type for use in image recognition applications. For example, to identify different fruit types, the neural network algorithm must be provided with multiple images of fruits which have been taken from different angles, have varying degrees of colour and be correctly labelled. The algorithm then identifies the specific features that it can use to distinguish one type of fruit from another. This training phase is an iterative process that may require adjusting the algorithm to improve the probability of correctly identifying a particular piece of fruit.
Figure 1: training and inference steps (Source: Mouser)
Once the algorithm has been trained to meet the desired level of performance, the model can then be deployed in a real-world application to perform probability-based inferencing of results.
A smart speaker requires a ‘wake word’ (or phrase) like ‘Alexa’ to make it aware that it is about to perform a task. Since it does not have much computing power, it records short audio clips which it then streams to the cloud where inferencing is then used to identify the most likely task to be performed. Simple machine learning, now commonly called TinyML, is used to identify a ‘wake word’ or phrase.
Industrial IoT (IIoT) applications for Machine Learning
The number of potential applications for ML is significant and continues to grow. Industrial applications aim to exploit ML to increase the efficiency of production lines by reducing the amount of downtime due to unexpected faults. Here. ML can be used to improve the effectiveness of predictive maintenance routines. For example, it can be used to monitor the performance of motors and actuators by detecting the type of abnormal vibrations which may indicate that machine failure may be imminent.
ML has huge potential for use in industry, but this environment presents many technical challenges to its application. When compared to datacentres, which have a near-limitless level of computing resources, the processing power and memory size of an IIoT edge sensor is relatively tiny. Since a single factory can use dozens of sensors, form factor, and available power supply, connectivity become increasingly important. Thankfully, the neural network algorithms used by these sensors require fewer computing resources, so embedded developers are now investigating ways in which they can be performed by battery powered microcontrollers.
TinyML: Edge based Machine Learning
The computing platform used when training a neural network model (which is highly resource intensive) is vastly different to that used when the algorithm is deployed in a real-world application, but there are still several technical challenges to be overcome. An important question that must be answered is the ability of the algorithm to provide results in an acceptable timescale. Similarly, the way a sensor communicates with its host system (to notify operators of results) must be addressed. This creates a challenge for embedded developers who are faced with the considerable task of learning the concepts of machine learning and working with neural networks.
The process of choosing a neural network model, then training and adjusting so that it is suitable for real-world deployment is complex. However, an ever-growing repository of machine learning libraries, frameworks, and development tools are helping to simplify this task, making it easier for them to be deployed on microcontrollers. Regardless of your edge-based application, the increasing number of AI/ML resources specially designed for TinyML means that assistance is always available, with Mouser now also providing examples of useful machine learning projects. AI/ML is quickly becoming a major enabler of the digital transformation in industrial applications. It has evolved to the point that it is now practical to deploy in edge-based devices like sensors on a factory floor. The increasing popularity of ML means it will be a key driver of higher efficiency and productivity in future industrial applications.