Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c1c8168
update optimization
awaelchli Mar 13, 2023
0504638
update inception
awaelchli Mar 13, 2023
da590db
update attention
awaelchli Mar 13, 2023
ec3d50a
incomplete GNN
awaelchli Mar 13, 2023
0b92f1d
update energy models
awaelchli Mar 13, 2023
a5466e4
update deep autoencoders
awaelchli Mar 13, 2023
88722ac
normalizing flows incomplete
awaelchli Mar 13, 2023
47f1cfe
autoregressive
awaelchli Mar 13, 2023
cfab2ee
vit
awaelchli Mar 13, 2023
b4d7be3
meta learning
awaelchli Mar 13, 2023
8ab731c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 13, 2023
18c2430
Apply suggestions from code review
awaelchli Mar 13, 2023
000c803
update gnn
awaelchli Mar 13, 2023
3824605
simclr
awaelchli Mar 13, 2023
d1a93e7
update
awaelchli Mar 13, 2023
6e04b38
Merge branch 'upgrade/course' of github.com:Lightning-AI/tutorials in…
awaelchli Mar 13, 2023
9377298
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 13, 2023
b24b122
Update course_UvA-DL/05-transformers-and-MH-attention/Transformers_MH…
awaelchli Mar 13, 2023
099c50a
update
awaelchli Mar 13, 2023
82f2be6
links
awaelchli Mar 13, 2023
a6a1a17
Merge branch 'main' into upgrade/course
Borda Mar 14, 2023
5733cc0
Merge branch 'main' into upgrade/course
Borda Mar 14, 2023
28accf9
2.0.0rc0
Borda Mar 14, 2023
10615e9
lightning
Borda Mar 14, 2023
217be55
2.0
Borda Mar 14, 2023
1dc811a
Apply suggestions from code review
awaelchli Mar 14, 2023
bb1e40a
docs build fix
awaelchli Mar 14, 2023
835a628
stupid sphinx
awaelchli Mar 14, 2023
94e6725
Merge branch 'main' into upgrade/course
Borda Mar 14, 2023
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
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.14.5
# ---

# %% [markdown]
# <div class="center-wrapper"><div class="video-wrapper"><iframe src="https://www.youtube.com/embed/wnKZZgFQY-E" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div></div>
# Welcome to our PyTorch tutorial for the Deep Learning course 2020 at the University of Amsterdam!
Expand Down Expand Up @@ -37,13 +25,13 @@
import time

import matplotlib.pyplot as plt

# %matplotlib inline
import matplotlib_inline.backend_inline
import numpy as np
import torch
import torch.nn as nn
import torch.utils.data as data

# %matplotlib inline
import matplotlib_inline.backend_inline
from matplotlib.colors import to_rgba
from torch import Tensor
from tqdm.notebook import tqdm # Progress bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from urllib.error import HTTPError

import matplotlib.pyplot as plt

# %matplotlib inline
import matplotlib_inline.backend_inline
import numpy as np
import seaborn as sns
import torch
Expand All @@ -19,9 +22,6 @@
import torch.optim as optim
import torch.utils.data as data
import torchvision

# %matplotlib inline
import matplotlib_inline.backend_inline
from torchvision import transforms
from torchvision.datasets import FashionMNIST
from tqdm.notebook import tqdm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.14.5
# ---

# %% [markdown]
# <div class="center-wrapper"><div class="video-wrapper"><iframe src="https://www.youtube.com/embed/X5m7bC4xCLY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div></div>
# In the first half of the notebook, we will review different initialization techniques, and go step by step from the simplest initialization to methods that are nowadays used in very deep networks.
Expand All @@ -25,17 +13,17 @@
import urllib.request
from urllib.error import HTTPError

import lightning as L
import matplotlib.pyplot as plt

# %matplotlib inline
import matplotlib_inline.backend_inline
import numpy as np
import lightning as L
import seaborn as sns
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data as data

# %matplotlib inline
import matplotlib_inline.backend_inline
from matplotlib import cm
from torchvision import transforms
from torchvision.datasets import FashionMNIST
Expand Down Expand Up @@ -952,7 +940,7 @@ def plot_curve(
fig = plt.figure()
ax = fig.gca()
if plot_3d:
ax = fig.add_subplot(projection='3d')
ax = fig.add_subplot(projection="3d")

x = torch.arange(x_range[0], x_range[1], (x_range[1] - x_range[0]) / 100.0)
y = torch.arange(y_range[0], y_range[1], (y_range[1] - y_range[0]) / 100.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.14.5
# ---

# %% [markdown]
# <div class="center-wrapper"><div class="video-wrapper"><iframe src="https://www.youtube.com/embed/vjSSyGxlczs" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div></div>
# Let's start with importing our standard libraries here.
Expand All @@ -20,10 +8,11 @@
from types import SimpleNamespace
from urllib.error import HTTPError

import lightning as L
import matplotlib
import matplotlib.pyplot as plt
import matplotlib_inline.backend_inline
import numpy as np
import lightning as L
import seaborn as sns
import tabulate
import torch
Expand All @@ -34,10 +23,8 @@

# %matplotlib inline
from IPython.display import HTML, display
import matplotlib_inline.backend_inline

from PIL import Image
from lightning.pytorch.callbacks import LearningRateMonitor, ModelCheckpoint
from PIL import Image
from torchvision import transforms
from torchvision.datasets import CIFAR10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
from functools import partial
from urllib.error import HTTPError

# PyTorch Lightning
import lightning as L

# Plotting
import matplotlib
import matplotlib.pyplot as plt
import matplotlib_inline.backend_inline
import numpy as np

# PyTorch Lightning
import lightning as L
import seaborn as sns

# PyTorch
Expand All @@ -52,7 +53,6 @@

# Torchvision
import torchvision
import matplotlib_inline.backend_inline
from lightning.pytorch.callbacks import ModelCheckpoint
from torchvision import transforms
from torchvision.datasets import CIFAR100
Expand Down
13 changes: 7 additions & 6 deletions course_UvA-DL/06-graph-neural-networks/GNN_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,26 +634,27 @@ def test_step(self, batch, batch_idx):
# Additionally to the Lightning module, we define a training function below.
# As we have a single graph, we use a batch size of 1 for the data loader and share the same data loader for the train,
# validation, and test set (the mask is picked inside the Lightning module).
# Besides, we set the argument `progress_bar_refresh_rate` to zero as it usually shows the progress per epoch,
# Besides, we set the argument `enable_progress_bar` to False as it usually shows the progress per epoch,
# but an epoch only consists of a single step.
# If you have downloaded the pre-trained models in the beginning of the tutorial, we load those instead of training from scratch.
# Finally, we test the model and return the results.


# %%
def train_node_classifier(model_name, dataset, **model_kwargs):
pl.seed_everything(42)
L.seed_everything(42)
node_data_loader = geom_data.DataLoader(dataset, batch_size=1)

# Create a PyTorch Lightning trainer
root_dir = os.path.join(CHECKPOINT_PATH, "NodeLevel" + model_name)
os.makedirs(root_dir, exist_ok=True)
trainer = pl.Trainer(
trainer = L.Trainer(
default_root_dir=root_dir,
callbacks=[ModelCheckpoint(save_weights_only=True, mode="max", monitor="val_acc")],
gpus=AVAIL_GPUS,
accelerator="auto",
devices=AVAIL_GPUS,
max_epochs=200,
progress_bar_refresh_rate=0,
enable_progress_bar=False,
) # 0 because epoch size is 1
trainer.logger._default_hp_metric = None # Optional logging argument that we don't need

Expand All @@ -663,7 +664,7 @@ def train_node_classifier(model_name, dataset, **model_kwargs):
print("Found pretrained model, loading...")
model = NodeLevelGNN.load_from_checkpoint(pretrained_filename)
else:
pl.seed_everything()
L.seed_everything()
model = NodeLevelGNN(
model_name=model_name, c_in=dataset.num_node_features, c_out=dataset.num_classes, **model_kwargs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
import urllib.request
from urllib.error import HTTPError

# PyTorch Lightning
import lightning as L

# Plotting
import matplotlib
import matplotlib.pyplot as plt
import numpy as np

# PyTorch Lightning
import lightning as L
# %matplotlib inline
import matplotlib_inline.backend_inline
import numpy as np

# PyTorch
import torch
Expand All @@ -25,9 +28,6 @@

# Torchvision
import torchvision

# %matplotlib inline
import matplotlib_inline.backend_inline
from lightning.pytorch.callbacks import Callback, LearningRateMonitor, ModelCheckpoint
from torchvision import transforms
from torchvision.datasets import MNIST
Expand Down
16 changes: 2 additions & 14 deletions course_UvA-DL/08-deep-autoencoders/Deep_Autoencoders.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.14.5
# ---

# %% [markdown]
# <div class="center-wrapper"><div class="video-wrapper"><iframe src="https://www.youtube.com/embed/E2d8NRYt2e4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div></div>

Expand All @@ -18,17 +6,17 @@
import urllib.request
from urllib.error import HTTPError

import lightning as L
import matplotlib
import matplotlib.pyplot as plt
import lightning as L
import matplotlib_inline.backend_inline
import seaborn as sns
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data as data
import torchvision
import matplotlib_inline.backend_inline
from lightning.pytorch.callbacks import Callback, LearningRateMonitor, ModelCheckpoint
from torch.utils.tensorboard import SummaryWriter
from torchvision import transforms
Expand Down
6 changes: 3 additions & 3 deletions course_UvA-DL/09-normalizing-flows/NF_image_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import urllib.request
from urllib.error import HTTPError

import lightning as L
import matplotlib
import matplotlib.pyplot as plt
import matplotlib_inline.backend_inline
import numpy as np
import lightning as L
import seaborn as sns
import tabulate
import torch
Expand All @@ -23,9 +24,8 @@
import torch.utils.data as data
import torchvision
from IPython.display import HTML, display
import matplotlib_inline.backend_inline
from matplotlib.colors import to_rgb
from lightning.pytorch.callbacks import LearningRateMonitor, ModelCheckpoint
from matplotlib.colors import to_rgb
from torch import Tensor
from torchvision import transforms
from torchvision.datasets import MNIST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@
import urllib.request
from urllib.error import HTTPError

import lightning as L

# Imports for plotting
import matplotlib.pyplot as plt
import matplotlib_inline.backend_inline
import numpy as np
import lightning as L
import seaborn as sns
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data as data
import torchvision
import matplotlib_inline.backend_inline
from matplotlib.colors import to_rgb
from lightning.pytorch.callbacks import LearningRateMonitor, ModelCheckpoint
from matplotlib.colors import to_rgb
from torch import Tensor
from torchvision import transforms
from torchvision.datasets import MNIST
Expand Down
4 changes: 2 additions & 2 deletions course_UvA-DL/11-vision-transformer/Vision_Transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import urllib.request
from urllib.error import HTTPError

import lightning as L
import matplotlib
import matplotlib.pyplot as plt
import lightning as L
import matplotlib_inline.backend_inline
import seaborn as sns
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data as data
import torchvision
import matplotlib_inline.backend_inline
from lightning.pytorch.callbacks import LearningRateMonitor, ModelCheckpoint
from torchvision import transforms
from torchvision.datasets import CIFAR10
Expand Down
6 changes: 3 additions & 3 deletions course_UvA-DL/12-meta-learning/Meta_Learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
from statistics import mean, stdev
from urllib.error import HTTPError

import lightning as L
import matplotlib
import matplotlib.pyplot as plt
import matplotlib_inline.backend_inline
import numpy as np
import lightning as L
import seaborn as sns
import torch
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data as data
import torchvision
import matplotlib_inline.backend_inline
from PIL import Image
from lightning.pytorch.callbacks import LearningRateMonitor, ModelCheckpoint
from PIL import Image
from torchvision import transforms
from torchvision.datasets import CIFAR100, SVHN
from tqdm.auto import tqdm
Expand Down