Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions lessons/04_ML_deep_learning/02_pytorch_intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Introduction to PyTorch
PyTorch is an open-source tool for building neural network models, originally developed by Facebook's AI Research lab. Because of its intuitive design, it has become one of the most popular frameworks for deep learning and artificial intelligence research.

Aside from its intuitive interface, PyTorch has many features that make it a great choice for building deep learning models. It includes a basic library for tensor computations, very similar to NumPy, but with strong GPU acceleration support. It also provides built-in tools to build neural networks and calculate gradients, which is required for backpropagation. Also, unlike the other major frameworks like Tensorflow, PyTorch works very hard to ensure it is easy to install and integrate with your GPU on multiple platforms (including Windows).

For this first lesson, we want to just build some familiarity with PyTorch independently of neural networks, and focus on its ability to do numerical computing similar to NumPy but with GPU acceleration.

For this lesson, we will use the official PyTorch tutorial notebook on tensors. While you can run it locally if you install PyTorch on your machine, we recommend using Kaggle to avoid installation issues:

[![Open in Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://www.kaggle.com/kernels/welcome?src=https://github.com/Code-the-Dream-School/python-200/blob/ml/pytorch_intro/lessons/04_ML_deep_learning/resources/pytorch_tensors.ipynb)

Click the "Open in Kaggle" button above to open the notebook in Kaggle.

In that notebook, focus on these sections:
- Creating tensors
- Random tensors and seeding
- Shapes and dtypes
- Basic mathematical operations

What to skim for now:
- Broadcasting
- requires_grad / autograd-related details

For now, we are just treating PyTorch as a library for tensor operations, similar to NumPy. In future lessons, we will build on this foundation to create neural networks and train them using backpropagation (as discussed in the introduction to neural networks and deep learning).

## Additional Resources
If you want additional material on learning basic PyTorch:
- [learnpytorch.io](https://www.learnpytorch.io/00_pytorch_fundamentals/)
- [YouTube Video](https://www.youtube.com/watch?v=v43SlgBcZ5Y)

In that video the author assumes you are using conda to manage your Python environment, but you can just import torch in Kaggle without worrying about that. Also, if you want to install PyTorch on your own machine, you can find out how at their [official installation page](https://pytorch.org/get-started/locally/). It is very easy to install compared to other deep learning frameworks.






6 changes: 5 additions & 1 deletion lessons/04_ML_deep_learning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ After exploring the fundamentals of deep learning, we will use the pytorch libra

Our goal is to equip you with the skills needed to build and deploy deep learning models for various applications, not to become deep learning researchers or academics. As usual, the focus is on building intuition and understanding, not on deep mathematical theory.

For our hands-on excercises, we will be using PyTorch, which is one of the most popular deep learning frameworks. We will be using PyTorch on Kaggle for our lessons and assignments, so we don't have to worry about installation issues. However, if you want to install PyTorch on your own machine for practice, you can find out how at their [official installation page](https://pytorch.org/get-started/locally/).

IN our hands-on lessons, we will gently build up in complexity. We will start by treating PyTorch as a library for array (or tensor) operations like NumPy, and then we will build simple neural networks from scratch. After that, we will explore more complex architectures like convolutional neural networks (CNNs) for image classification, and finally we will explore transfer learning, which is a powerful technique that allows us to leverage pre-trained models for new tasks with limited data.

> To fill in later: brief motivational preview here. Briefly explain why this lesson matters, what students will be able to do by the end, and what topics will be covered. Keep it tight and motivating.

> For an introduction to the course, and a discussion of how to set up your environment, please see the [Welcome](../README.md) page.
Expand All @@ -16,7 +20,7 @@ Our goal is to equip you with the skills needed to build and deploy deep learnin
A brief introduction to neural networks and deep learning, including biological inspiration, architecture, and common use cases.

2. [Introduction to pytorch](02_pytorch_intro.md)
An overview of the pytorch library, mainly focusing on installation, and tensor operations: we will direct you to the excellent tutorial at learnpytorch.io to learn the basics of pytorch.
An overview of the PyTorch library, mainly focusing on tensor operations: we will direct you to the excellent tutorial at learnpytorch.io to learn the basics of pytorch.

1. [Training your first neural network](03_xor.md)
Before diving into more complex models, we will start with a simple example with a neural network. This will help us understand the basic workflow for training a model in pytorch.
Expand Down
Loading