Note · Machine Learning
A Brief Introduction to Deep Learning
A bird's eye view of a tremendously deep field within machine learning.
Deep learning a subfield of machine learning. Basic knowledge of machine learning is a helpful foundation for deep learning but you’ll pick these up as you learn about deep learning.
Neural Networks as Universal Function Approximators
Artificial neural networks (ANNs) are universal function approximators. Theoretically, with proper design, they can take any input space, and map it to any output space. Typically, an ANN can be described as where is the dimensionality of the input and is the dimensionality of the output.
Objective Functions
While neural networks can appear quite magical to people not familiar with them, conceptually they’re actually pretty straightforward. Loosely speaking, because neural networks have some much flexibility in the outputs they can produce, they need a lot of data to be trained on in order to be able to produce reasonable outputs.
Instead of providing a neural network with how we want it to find the answer, only tell it what the answer is. When the neural network produces an answer close to what is desired, we don’t tell it to change but when it performs poorly, we tell it to change a lot. The number that determines how much the neural network needs to change is called the cost function. Cost functions and objective functions are closely related. By minimizing a cost function, you are maximizing your implied objective function.
To train a neural network we need input-output pairs like this: . The loss function if we were minimizing squared error would look like this:
Which would imply our objective function is something like:
We’ll explain what is in the next section.
Typical Form for
Deep neural networks take in an input, multiply it by a linear transformation followed by a non-linear activation before being “passed to the next layer”. The next layer treats the output from the previous layer as an input and repeats the same process. The non-linear transformations in addition to incorporating many layers are what give artificial neural networks their flexibility.
Let describe the linear transformation that layer performs on the input and be the dimension of that input with being the dimension of the output at layer which is also the input for layer . Furthermore, let be some function that is a non-linear mapping from each scalar in the input to another scalar. Finally let be our input. Then for an layer ANN we can describe it with a function:
If this is your first time seeing this, it probably looks like gibberish which is why networks are usually diagrammed in a form that resembles this:
Where is the output from the previous layer.
Training, Validating, and Testing
When training a neural network, you have to make sure that your the training data your using is representative of the population for which you want to generate predictions.
Generally data will be used as following.
First we find observations to use for training out model. Then we partition this bank of observations into three sets, .
The set is what we’re allowed to use in our quest to tune the weights () of our model.
The set is what we use during training to make sure we’re not overfitting.
Finally, the set should not be touched until after the model has been fully trained. Seeing how to the model performs on the set should give us an idea of how well we might expect our model to perform on brand-new data once we use it to make predictions in the real world.
Some Neural Network Anatomy
The entire in the matrices are called “weights” these are what get adjusted when a neural network is being trained.
Each is usually picked from a fairly small set of what are called “activation functions”. Some population activation functions include the sigmoid, ReLU, Leaky ReLU, and TanH. As was mentioned earlier, activation functions are what provide neural networks their flexibility because activation function are non-linear. Otherwise, an entire network could be described perfectly by one weight matrix:
Why learn the “math” of neural networks and not just the intuition?
Though diagrams are helpful for understanding the general design of a network, they leave the details of how the network functions ambiguous. Typically, diagrams are used to make deep learning more approachable but for mathematically inclined individuals, it leaves details confused which can make replication of published models more difficult than necessary.
To increase clarity of various neural network designs, I plan to cover some canonical neural network designs with fairly rigorous mathematical notation.
For clarity on the type of operation that performs, if then