Deep Learning: Classifying Images with Neural Networks
Machine Learning or Automated Learning
Machine Learning or automated learning enables the identification of patterns in data based on algorithms that classify each factor according to its degree of influence, continuously learning and improving the process.
A previous post already introduced terms such as Artificial Intelligence, Machine Learning, or Deep Learning. In our daily lives, these concepts cross our path so frequently that it ends up being confusing to distinguish between them. Well, Frank Chen provides a good overview of how to distinguish them:
“Artificial intelligence is a set of algorithms and intelligence to try to mimic human intelligence. Machine learning is one of them, and deep learning is one of those machine learning techniques.”
Artificial intelligence is a set of algorithms and intelligence that attempt to simulate human intelligence. Machine Learning is one of those algorithms, and Deep Learning is one of the Machine Learning techniques.
Explained simply, Machine Learning feeds data to the computer and uses statistical techniques to help it “learn” how to progressively improve at a task without being specifically programmed for it, eliminating the need for millions of lines of code.
Machine Learning can be divided into two types of learning: supervised and unsupervised. While the former employs labeled data sets, the latter uses unlabeled data sets.
El Deep Learning, or aprendizaje profundo, is a branch of Machine Learning that introduces input data, inputs, through an artificial neural network architecture, which is inspired by biological ones. This artificial neural network contains a number of hidden layers that process the data, allowing the machine to “deepen” its learning by making connections and weighting inputs to obtain increasingly better results.
Figure 1. Basic structure of a neural network
Neural networks: the tools with which Deep Learning performs its magic
A neural network is nothing more than a handful of neurons connected to each other. They are based on a simple idea: given certain parameters, there is a way to combine them to predict a certain result. But what is the right combination? This is where the term training comes in, which consists of testing different semi-random combinations of parameters until the prediction error is minimized, thus achieving better predictions.
Normally, network training is performed on 75-80% of the total data, called the train set, while the remaining 20-25% is used as the test set.
This process prevents the network training from overfitting to a single set of data, performing validation on data that is “new” to the network, and thus evaluating the model’s generalization capability.
The learning process of a neural network is evaluated using learning curves, which normally show the evolution of the prediction error over time. In this way, the better the model, the lower the error, so a minimization of error is expected to be observed in the learning curve.
When a Machine or Deep Learning model is trained, the state of the model can be evaluated at each intermediate stage. When evaluated on the train set, we get an idea of how well our model is learning, whereas if it is evaluated on the test set, we get an idea of how well the model is able to generalize.
We will know that a model is well fitted when the train and test error curves reach a point of stability with a small separation between them.
Figure 2. Learning curves of the train and test sets as a function of model complexity.
And with images? Convolutional neural networks
Neural networks are very useful for performing classification or regression from an input datum using a trained model. This same idea can be applied to an image to obtain, for example, what the image represents (classification) or to detect an object that is part of it (segmentation, detection, identification, etc.). For this purpose, convolutional neural networks (CNN) are used, which have represented a revolution in the image recognition sector since, unlike conventional neural networks and other image classification algorithms, they use relatively little processing.
The network is trained from images using only pixels and labels as inputs. They learn by using filters and applying them to images. The algorithm takes a small square (or ‘window’) and begins to apply it over the image. Each filter allows the CNN to identify certain patterns in the image. The CNN looks for parts of the image where a filter matches the image content.
In this case, CNNs take shape tensors as input, which include the height and width of the image in pixels, and the number of color channels (1 if the image is in black and white, or 3 if it is in RGB color). The output would be the class or the probability that the image belongs to a particular class (Fig 3).
Figure 3. Structure of a convolutional neural network for image classification.
How can I build and train a CNN for image classification?
Keras is an open-source Neural Network library written in Python. In addition to support for standard neural networks, it offers support for Convolutional Neural Networks and Recurrent Neural Networks. It also contains several implementations of neural network building blocks: convolutional and pooling layers, activation functions, optimizers, etc.
As partners of KNIME, at LISDATA we advocate for this software for Deep Learning developments and for training neural network models for image classification.
KNIME provides customers with Python and Keras extensions, allowing them to build Deep Learning architectures and models in a simple and intuitive way, while also allowing for the documentation of the different nodes used.
Thinking humanly
Thinking rationally
Acting humanly
Acting rationally