Deep Learning Track WiSe 24/25
Deep Learning Track WiSe 24/25
Deep Learning Track WiSe 24/25
  • Welcome to the Deep Learning Track
  • Setup
  • Learning Material
  • Section 1 - The Math
    • Derivatives and Gradients
    • Vectors, Matrices and Tensors
    • The power of matrix computation
    • Exercise - Matrix Computation
  • Section 2 - The Data
    • PyTorch Datasets and Data Loaders
    • Working with Data Tables
    • Exercise - Loading Data from a CSV file
    • Working with Images
    • Exercise - Image Datasets
    • Working with Text
  • Section 3 - Neural Networks
    • Activation Functions
    • Exercise - Activation Functions
    • Exercise - The Softmax Function
    • The Neuron
    • Two type of applications: Regression and Classification
    • Loss Functions
    • Exercise - Regression Loss Functions
    • Exercise - Classification Loss Functions
    • The Gradient Descent Algorithm
    • Exercise - Implementing Gradient Descent
    • Exercise - PyTorch Autograd
    • Exercise - Regression with Neural Networks
    • Exercise - Classification with Neural Networks
    • Playground - Neural Networks
  • Section 4 - Convolutional Neural Networks
    • Convolution
    • Convolutional Neural Networks
    • Classifying handwritten digits
    • Playground - Convolutional Neural Networks
    • Transfer Learning
  • Final Project - Text Classification
  • Further Resources
    • Computer Vision Libraries
    • Image Classification with PyTorch
    • Object Detection with PyTorch
    • Deep AI Explainability
Powered by GitBook
On this page

Welcome to the Deep Learning Track

Welcome to the AI course of TechAcademy!

In this course we will teach you the basics of the modern approach to the topic of artificial intelligence - the neural networks. These models solve problems that have long been considered unsolvable by a computer, like image classification, precise language translation or even generating new content like text and images. But how actually can you do those things just by the power of math and a computer? This course will provide you the basic skills to understand what a neural network is, what you can do with it and how you can program your own neural network using the Python framework PyTorch, which is used by a lot of companies and universities today.

Agenda

Section 1: The math

Before we can start coding neural networks we need to understand the basic math that you need for them. But don't worry, math for AI is not that hard as you might think. Everything you need to know for this course you already learned in your A-levels.

The mathematics required for this course is limited to the following topics:

  • You can derive functions (analysis)

  • You understand vector and matrix calculus That is all. With this knowledge, you can already build and train neural networks. (linear algebra)

  • You understand what a probability function is (stochastics)

In order to deepen our mathematical knowledge once again, we will work on some practical notebooks on this topic, in which we will work through some tasks on these two topics as a warm-up. Especially we are having a look at matrix multiplication.

Notebooks:

  • The power of matrix multiplication: Let's see what matrix multiplication can do. You can rotate, translate and scale vectors just by multiplying them with a matrix. You can even increase or decrease the dimension of data points by matrix multiplication, which is an important concept if we want to map data points to classes in a classification problem oor to predict y-values in a regression probllem. In this notebook you will plot the input vectors before multiplying them with a matrix and the results after multiplying them with a matrix.

Skills you learn in this section:

  • You have reperated the basics of function derivation (df/dx)

  • You have a visual intuition what can be done with matrix multiplication (rotation, translation, scaling, projection)

Section 2: The data

In this section we will introduce the concept of tensors, which are basically high dimensional matrices or data tables. We will learn how we can represent and transform different data types like tabular data, images or text into tensors.

In this section we start coding by building a data loader class which will bre responsible for loading data from our disk and turn it into a tensor.

Notebooks

  • Notebook 1: Load data from a CSV file and transform it into a tensor. Iterate over the data points and print them.

  • Noteboook 2: Load images from the disk with a data loader and iterate over them. Apply image augmentation to the data like rotating the images, so that the more variance is added to the data. This can help neural networks to achieve better results.

Skills you learn in this section:

  • You understand what a tensor is

  • You can build a data loader class with PyTorch

  • You can turn data tables, images and text into tensors

Section 3: The neuron

The basic building block of a neural network is a neuron. We will talk about what a (mathematical) neuron is, what it has to do with matrices and what it is able to do. You don't need to know a lot of math, because neurons are actually very simple. You just need to know how to multipy two matrices and then apply a function to the resullting vector. That's all. It is more important to visually see what a neuron can do by plotting the input and output vectors of a neuron which we will do using matplotlib. We will also see that we can build complex functions just by building layers of parallel neurons and networks of chained neuron layers.

After we have seen the power of matrix multipication we will have a look on the second part of a neuron - the activation function. An activation function works like a filter that excludes data points from the operation a matrix applies to the data points. This is necessary because matrix multipplication is a linear operation, which means the same operation is applied to all data points. If we want to apply a transformation like rotation only to a fraction of the data points we need activation function to define which data points should be transformed and which should not. We will build two neurons in this notebook. The first one rotates half of the data points to the left, the other neuron rotates the other half of the data points to the right. Finally we reduce the dimension of the rotated data points with another neuron. Actually we now have built our first neural network!

Notebooks:

  • Activation functions: learn about Sigmoid, TanH, ReLU and LeakyReLU - the most used activation functions in neural networks

Section 4: The Gradient Descent Algorithm

After we understood what a neural network actually is - namely a transformation of data points from one shape into another shape - we can now have a look on how we train these networks to do what we actually want them to do. In this lecture we introduce terms like loss functions and gradients which can help us to find the right parameters of a model. You will see that math you learnt in school is absolutely sufficient to compute all we need so that a neural network can actually find the best parameters.

  • Notebook 1: We will implement the backpropagation algorithm by applying it to a very easy example. We train a linear function of the form y = a*x, where a is the only parameter we can choose, to go through a single data point by defining a loss function, computing the gradient of the loss function and then use this gradient to update the parameter of our linear function. We will do this until the linear function goes through the given data point. We will see that the backpropagation algorithm actually is very simple, and neural networks use the same algorithm just for learning more complex functions. We will have a look at the L1 and L2 loss functions and check which one works better for our example.

  • Notebook 2: After we have trained the linear function of form y=a*x with the backpropagation algorithm we will see how we can train a function of the form y=a*x+b, which has two parameters. This is neccessary to understand layers in a neural network, where we have multiple input variables.

Skills learned in this section:

  • You know what a gradient is

  • You know what a loss function is

  • You know when to use Mean Squared Error Loss and Cross Entropy Loss

Section 5: Writing our own neural networks with PyTorch

Until now we have written our neural networks by hand, so it is time to introduce a framework which actually can help us doing this. We will build two neural networks with PyTorch that will work with the data of our CSV files. The first network performs a regression on our data points. The second notebook will classify data points in another CSV file. Most of the code will be already implemented in those notebooks, your task will be to understand this code and fill the missing parts.

  • Notebook 1: You will load data from a CSV file and plot the data points. You will see that the data points look like a parabola. We will now train a neural network that tries to predict this parabola. You will use the data loader defined in the previous lectures and run these data points through the neural network. We will use PyTorch to define a neural network, choose which loss function we will use, compute the gradients by comparing the predictions of the neural network to the true outputs and optimizing the parameters by performing the backpropagation step. You will see that PyTorch hides all the math from you, which is great because it makes the code very readable. However it is good to know what PyTorch is actually doing under the hood, which is why we have done the mathematical lectures before.

  • Notebook 2: In this notebook we will use the famous IRIS dataset, which contains some metrics about flowers. Your task will be to predict the type of flower based on those metrics. So in this notebook we will introduce classification problems and how you can solve them with PyTorch.

After this lecture you are able to understand the fundamentals of PyTorch like data loaders, neural network definitions, training loops, the computation of the loss and the update step. You will find these concept in all PyTorch projects, whether you are predicting data points, classifying images or translating text.

Final Project: Text classification and transfer learning

In this lecture we are finally working with more complex data. We build a neural network that is able to classify images. For that we will work with the MNIST dataset which contains black and white images of handwritten numbers. When working with images we need a new kind of layer in our neural network which is called a convolutional layer. We will see what this kind of layer can do, how it helps us to extract information from an image and how we can build a convolutional neural network with PyTorch. Also we will talk about the concept of transfer learning, which means that we will load a pretrained neural network and only train the last classification layer. We will see that this is much more efficient than training our own network from scratch, needs less time for training and achieving better results.

  • Notebook 1: Understanding convolutional layers. We will have a look at convolutional layers in convolutional neural networks. You will get a notework where you will find a symbol in an image by programming a matrix that is slided over the image and multiplied with the overlapping image fraction time. The result of this operation will be a heatmap which has the highest value at the point where the symbol is located. For simplicity we will do this with a simple black and white image and with simple symbols like a diamond and a square. This is essential for understanding how convolutional neural networks work.

  • Notebook 2: Load the MNIST dataset and visualize it using matplotlib. We will have a look on the dataset in this notebook, so that we can see how the images actually look like. We will then define our own simple convolutional neural network and train it on the MNIST dataset. Again most of the code in the notebook will be written fro you. You task is to fill the missing parts.

  • Notebook 3: We will replace our own convolutional network by a pretrained neural network named "MobileNet". You will learn how you can load pretrained neural networks from PyTorch Hub and how you can adapt these networks to your own classification problems. We will train MobileNet on the MNIST dataset and compare the results to our own convolutional network. You are free to try other pretrained convolutional networks like ResNet or EfficientNet if you like. If you feel secure with convolutional networks you can even try to classify images of cats and dogs or of different flower types.

NextSetup

Last updated 6 months ago