Perhaps the most positive technical theme of 2016 was the long-delayed triumph of artificial intelligence, machine learning, and in particular deep learning. In this article we’ll discuss what that means and how you might make use of deep learning yourself.
Perhaps you noticed in the fall of 2016 that Google Translate suddenly went from producing, on the average, word salad with a vague connection to the original language to emitting polished, coherent sentences more often than not — at least for supported language pairs, such as English-French, English-Chinese, and English-Japanese. That dramatic improvement was the result of a by the Google Brain and Google Translate teams to revamp Translate from using its old phrase-based statistical machine translation algorithms to working with a neural network trained with deep learning and word embeddings employing .
Was that magic? No, not at all: It wasn’t even easy. The researchers working on the conversion had access to a huge corpus of translations from which to train their networks, but they soon discovered that they needed thousands of GPUs for training and would have to create a new kind of chip, a Tensor Processing Unit (TPU), to run Translate on their trained neural networks at scale. They also had to refine their networks hundreds of times as they tried to train a system that would be nearly as good as human translators.
Do you need to be Google scale to take advantage of deep learning? Thanks to cloud offerings, the answer is an emphatic no. Not only can you run cloud VM and container instances with many CPU cores and large amounts of RAM, you can get access to GPUs, as well as prebuilt images that include deep learning software.
for an example), then split it randomly into two groups: one for training and one for testing. When you process the data for training, you use the known target value; when you process the data for testing, you predict the target value from the other data (no peeking!) and compute the error rates by comparing the prediction to the known target value.
Microsoft’s shown above is a good resource for picking algorithms, especially if you’re using Azure ML or another general-purpose ML library or service. For the case of stock market data, Decision Forest (known for accuracy and fast training) might be a good first algorithm for regression, Logistic Regression (fast training, linear model) might be a good first algorithm for two-class classification, and Decision Jungle (accuracy, small memory footprint) might be a good first algorithm for multiclass classification.
By the way, the only way to find the best algorithm is to try them all. Some ML packages and services, such as Spark.ML, can parallelize that for you and help pick the best result.
Note that neural networks are an option for any of the three kinds of prediction problems. Also note that neural networks are known both for accuracy and long training times. So what are neural networks, other than one of the more time-consuming but accurate approaches to machine learning?
The ideas for neural networks go back to the 1940s. The essential concept is that a network of artificial neurons built out of interconnected threshold switches can learn to recognize patterns in the same way that an animal brain and nervous system (including the retina) does.
The learning occurs basically by strengthening the connection between two neurons when both are active at the same time during training; in modern neural network software this is most commonly a matter of increasing the weight values for the connections between neurons using a rule called back propagation of error, backprop, or BP.
How are the neurons modeled? Each has a propagation function that transforms the outputs of the connected neurons, often with a weighted sum. The output of the propagation function passes to an activation function, which fires when its input exceeds a threshold value.
In the 1940s and ’50s artificial neurons used a step activation function and were called perceptrons. Modern neural networks may reference perceptrons, but actually have smooth activation functions, such as the logistic or sigmoid function, the hyperbolic tangent, and the Rectified Linear Unit (ReLU). ReLU is usually the best choice for fast convergence, although it has an issue of neurons “dying” during training if the learning rate is set too high.
The output of the activation function can pass to an output function for additional shaping. Often, however, the output function is the identity function, meaning that the output of the activation function is passed to the downstream connected neurons.
Now that we know about the neurons, we need to learn about the common neural network topologies. In a feed-forward network, the neurons are organized into distinct layers: one input layer, N hidden processing layers, and one output layer, and the outputs from each layer go only to the next layer.
In a feed-forward network with shortcut connections, some connections can jump over one or more intermediate layers. In recurrent neural networks, neurons can influence themselves, either directly, or indirectly through the next layer.
Supervised learning of a neural network is done exactly like any other machine learning: You present the network with groups of training data, compare the network output with the desired output, generate an error vector, and apply corrections to the network based on the error vector. Batches of training data that are run together before applying corrections are called epochs.
For those interested in the details, back propagation uses the gradient of the error (or cost) function with respect to the weights and biases of the model to discover the correct direction to minimize the error. Two things control the application of corrections: the optimization algorithm and the learning rate variable, which usually needs to be small to guarantee convergence and avoid causing dead ReLU neurons.
Optimizers for neural networks typically use some form of gradient descent algorithm to drive the back propagation, often with a mechanism to help avoid becoming stuck in local minima, such as optimizing randomly selected minibatches (Stochastic Gradient Descent) and applying momentum corrections to the gradient. Some optimization algorithms also adapt the learning rates of the model parameters by looking at the gradient history (AdaGrad, RMSProp, and Adam).
As with all machine learning, you need to check the predictions of the neural network against a separate test data set. Without doing that, you risk creating neural networks that only memorize their inputs instead of learning to be generalized predictors.
Now that you know something about machine learning and neural networks, it’s only a small step to understanding the nature of deep learning algorithms.
The dominant deep learning algorithms are deep neural networks (DNNs), which are neural networks constructed from many layers (hence the term “deep”) of alternating linear and nonlinear processing units, and are trained using large-scale algorithms and massive amounts of training data. A deep neural network might have 10 to 20 hidden layers, whereas a typical neural network may have only a few.
The more layers in the network, the more characteristics it can recognize. Unfortunately, the more layers in the network, the longer it will take to calculate, and the harder it will be to train.
Another kind of deep learning algorithm is Random Decision Forests (RDFs). Again, they are constructed from many layers, but instead of neurons the RDF is constructed from decision trees and outputs a statistical average (mode or mean) of the predictions of the individual trees. The randomized aspects of RDFs are the use of bootstrap aggregation (bagging) for individual trees and taking random subsets of the features.
Understanding why deep learning algorithms work is nontrivial. I won’t say that nobody knows why they work, since there have been papers on the subject, but I will say there doesn’t seem to be widespread consensus about why they work or how best to construct them.
The Google Brain people creating the deep neural network for the new Google Translate didn’t know ahead of time what algorithms would work. They had to iterate and run many weeklong experiments to make their network better, but sometimes hit dead ends and had to backtrack. (According to the New York Times article cited earlier, “One day a model, for no apparent reason, started taking all the numbers it came across in a sentence and discarding them.” Oops.)
There are many ways to approach deep learning, but none are perfect, at least not yet. There are only better and worse strategies for each application.
Deep learning strategies, tactics, and applications
For an example of an application of deep learning, let’s take image recognition. Since living organisms process images with their visual cortex, many researchers have taken the architecture of the visual cortex as a model for neural networks designed to perform image recognition. The biological research goes back to the 1950s.
The breakthrough in the neural network field for vision was Yann LeCun’s 1998 LeNet-5, a seven-level convolutional neural network (CNN) for recognition of handwritten digits digitized in 32-by-32-pixel images. To analyze higher-resolution images, the network would need more neurons and more layers.
Since then, packages for creating CNNs and other deep neural networks have proliferated. These include , , , , , , and .
Convolutional neural networks typically use convolutional, pooling, ReLU, fully connected, and loss layers to simulate a visual cortex. The convolutional layer basically takes the integrals of many small overlapping regions. The pooling layer performs a form of nonlinear down-sampling. ReLU layers, which we mentioned earlier, apply the nonsaturating activation function f(x) = max(0,x). In a fully connected layer, the neurons have full connections to all activations in the previous layer. A loss layer computes how the network training penalizes the deviation between the predicted and true labels, using a Softmax or cross-entropy loss for classification or an Euclidean loss for regression.