Introduction to deep learning with PyTorch

1. Introduction to deep learning with PyTorch

Hi. I'm Jasmin, a Senior Data Science Content Developer at DataCamp, and I'll be your instructor for this course on deep learning with PyTorch.

2. Deep learning is everywhere!

Deep learning is everywhere; it powers many recent and exciting innovations, from language translation

3. Deep learning is everywhere!

to self-driving cars,

4. Deep learning is everywhere!

medical diagnostics,

5. Deep learning is everywhere!

and chatbots.

6. What is deep learning?

Deep learning is a subset of machine learning, where the fundamental model structure is a network of inputs, hidden layers, and outputs, as shown. A network can have one

7. What is deep learning?

or many hidden layers.

8. Deep learning networks

The original intuition behind deep learning was to create models inspired by how the human brain learns: through interconnected cells called

9. Deep learning networks

neurons. This is why we continue to call deep learning models "neural" networks. These layered model structures require far more data compared to other machine learning models in order to derive patterns. We are usually talking about at least hundreds of thousands of data points.

10. PyTorch: a deep learning framework

While there are several frameworks and packages out there for implementing deep learning algorithms, we'll focus on PyTorch, one of the most popular and well-maintained frameworks. PyTorch was originally developed by Meta AI as part of Facebook's AI Research lab before it moved under the Linux Foundation. It is designed to be intuitive and user-friendly, sharing many similarities with the Python library NumPy.

11. PyTorch tensors

We can import the PyTorch module by calling import torch. The fundamental data structure in PyTorch is a tensor, which is similar to an array or matrix. It can support many mathematical operations and forms a building block for our neural networks. Tensors can be created from Python lists or NumPy arrays using the torch.tensor() class. This class converts the data into a compatible format for deep learning.

12. Tensor attributes

We can call tensor.shape to display the shape of our newly created tensor and tensor.dtype() to display its data type, here, a 64-bit integer. Checking the shape and data type ensures tensors align correctly with our model and task, and can help us in case of debugging.

13. Getting started with tensor operations

PyTorch tensors can be added or subtracted, provided that their shapes are compatible. Two tensors are compatible if they have the same shape, meaning their dimensions align exactly. When shapes are incompatible, we get an error.

14. Element-wise multiplication

We can also perform element-wise multiplication, which involves multiplying each corresponding element from two arrays of the same shape, and many other operations, including matrix multiplication.

15. Matrix multiplication

Matrix multiplication is a way of combining two matrices to make a new one.

16. Matrix multiplication

Each value in the new matrix comes from multiplying a row from the first matrix with a column from the second matrix and summing the results. Behind the scenes, deep learning models perform countless operations like addition and multiplication to process data and learn patterns.

17. Let's practice!

Let's manipulate some tensors!