Introduction to Artificial Intelligence
What does the term artificial intelligence mean, and what is the difference between the following terms:
- Artificial intelligence
- Machine learning
- Deep learning
We can use the following diagram to motivate the differences.
Artificial Neural Networks
Let's look at a typical diagram of a basic neural network:
This is a basic network that has \( 4 \) layers.
- \( 1 \) Input layer (Green)
- \( 2 \) Hidden layers (Black)
- \( 1 \) Output layer (Red)
Data flows through this network from left to right.
Each node in the network represents a number. The number of nodes in the input layer depends on the number of features in each sample of data. The number of nodes in the output layer depends on the number of labels or classes we have. The number of nodes in the hidden layers is arbitrary.
- Input layer nodes (Data)
- Hidden layer nodes (Arbitrary)
- Output layer nodes (Labels)
Each edge represents a parameter in the network. These parameters are called the network's weights. These values determine the network's mapping from input to output, and these are the values that are learned during the training process.
- Define the mapping
- Initialized randomly
- Updated during training
Neural Network workflow
When we are working with neural networks, there are \( 3 \) main steps.
- Prepare the data
- Train the network
- Predict with the network
Suppose we have a dataset of people. For each person, we have \( 2 \) attributes, height and weight and \( 2 \) labels, \( 0 \) for female and \( 1 \) for male.
|\( 1 \)||\( 50 \)||\( 6 \)||\( 0 \)|
|\( 2 \)||\( 60 \)||\( 7 \)||\( 1 \)|
|\( 3 \)||\( 75 \)||\( 7.5 \)||\( 1 \)|
|\( \vdots \)||\( \vdots \)||\( \vdots \)||\( \vdots \)|
The goal of training is to update the weights so that the network gives accurate predictions. To do this, we pass the data through the network. This is called a forward pass. We use linear algebra to do this.
Then, we check the accuracy of the network, and update the weights so that the accuracy goes up. We update the weights by going backwards though the network. This is called a backward pass. We use calculus to do this.
Then, we repeat.
- Forward pass uses linear algebra (matrix multiplication)
- Backward pass uses calculus (derivatives)
Here is the more verbose version of this process:
- Get batch from the training set.
- Pass batch to network.
- Calculate the loss (difference between the predicted values and the true values).
- Calculate the gradient of the loss function w.r.t the network's weights.
- Update the weights using the gradients to reduce the loss.
- Repeat steps 1-5 until one epoch is completed.
- Repeat steps 1-6 for as many epochs required to reach the minimum loss.
Save the learned weights and deploy.
Neural Networks in Practice
- Self driving car example 1
- Self driving car example 2
- Generated people
- Google text to speech
- Talk to transformer
- Chào bạn, mình thích uống chanh muối
- Training example in the browser
Developers and Deep Learning
In the past, developers would build applications primarily using text and numbers as input and output.
Deep learning enables developers to build applications that use images, audio, video and language as input and output.
Deep Learning Libraries
- PyTorch for Python
- TensorFlow for Python