Chapter 9. Neural Networks with OpenCV – an Introduction

Machine learning is a branch of artificial intelligence, one that deals specifically with algorithms that enable a machine to recognize patterns and trends in data and successfully make predictions and classifications.

Many of the algorithms and techniques used by OpenCV to accomplish some of the more advanced tasks in computer vision are directly related to artificial intelligence and machine learning.

This chapter will introduce you to the Machine Learning concepts in OpenCV such as artificial neural networks. This is a gentle introduction that barely scratches the surface of a vast world, that of Machine Learning, which is continuously evolving.

Artificial neural networks

Let's start by defining Artificial Neural Networks (ANN) with a number of logical steps, rather than a classic monolithic sentence using obscure jargon with an even more obscure meaning.

First of all, an ANN is a statistical model. What is a statistical model? A statistical model is a pair of elements, namely the space S (a set of observations) and the probability P, where P is a distribution that approximates S (in other words, a function that would generate a set of observations that is very similar to S).

I like to think of P in two ways: as a simplification of a complex scenario, and as the function that generated S in the first place, or at the very least a set of observations very similar to S.

So ANNs are models that take a complex reality, simplify it, and deduce a function to (approximately) represent statistical observations one would expect from that reality, in mathematical form.

The next step in our journey towards comprehending ANNs is to understand how an ANN improves on the concept of a simple statistical model.

What if the function that generated the dataset is likely to take a large amount of (unknown) inputs?

The approach that ANNs take is to delegate work to a number of neurons, nodes, or units, each of which is capable of "approximating" the function that created the inputs. Approximation is mathematically the definition of a simpler function that approximates a more complex function, which enables us to define errors (relative to the application domain). Furthermore, for accuracy's sake, a network is generally recognized to be neural if the neurons or units are capable of approximating a nonlinear function.

Let's take a closer look at neurons.

Neurons and perceptrons

The perceptron is a concept that dates back to the 1950s, and (to put it simply) a perceptron is a function that takes a number of inputs and produces a single value.

Each of the inputs has an associated weight that signifies the importance of the input in the function. The sigmoid function produces a single value:

Neurons and perceptrons

A sigmoid function is a term that indicates that the function produces either a 0 or 1 value. The discriminant is a threshold value; if the weighted sum of the inputs is greater than a certain threshold, the perceptron produces a binary classification of 1, otherwise 0.

How are these weights determined, and what do they represent?

Neurons are interconnected to each other, and each neuron's set of weights (these are just numerical parameters) defines the strength of the connection to other neurons. These weights are "adaptive", meaning they change in time according to a learning algorithm.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.176.99