diff --git a/course_UvA-DL/01-introduction-to-pytorch/.meta.yml b/course_UvA-DL/01-introduction-to-pytorch/.meta.yml index 34d1aed4a..ce7c76634 100644 --- a/course_UvA-DL/01-introduction-to-pytorch/.meta.yml +++ b/course_UvA-DL/01-introduction-to-pytorch/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 1: Introduction to PyTorch" author: Phillip Lippe created: 2021-08-27 -updated: 2021-11-29 +updated: 2023-01-04 license: CC BY-SA description: | This tutorial will give a short introduction to PyTorch basics, and get you setup for writing your own neural networks. diff --git a/course_UvA-DL/01-introduction-to-pytorch/Introduction_to_PyTorch.py b/course_UvA-DL/01-introduction-to-pytorch/Introduction_to_PyTorch.py index 74454e209..b8ece34bb 100644 --- a/course_UvA-DL/01-introduction-to-pytorch/Introduction_to_PyTorch.py +++ b/course_UvA-DL/01-introduction-to-pytorch/Introduction_to_PyTorch.py @@ -455,7 +455,7 @@ # Additionally, some operations on a GPU are implemented stochastic for efficiency # We want to ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False # %% [markdown] diff --git a/course_UvA-DL/02-activation-functions/.meta.yml b/course_UvA-DL/02-activation-functions/.meta.yml index 8fd86a8bc..9b435ff02 100644 --- a/course_UvA-DL/02-activation-functions/.meta.yml +++ b/course_UvA-DL/02-activation-functions/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 2: Activation Functions" author: Phillip Lippe created: 2021-08-27 -updated: 2021-08-27 +updated: 2023-01-04 license: CC BY-SA description: | In this tutorial, we will take a closer look at (popular) activation functions and investigate their effect on optimization properties in neural networks. diff --git a/course_UvA-DL/02-activation-functions/Activation_Functions.py b/course_UvA-DL/02-activation-functions/Activation_Functions.py index 9645ff57f..539f8c014 100644 --- a/course_UvA-DL/02-activation-functions/Activation_Functions.py +++ b/course_UvA-DL/02-activation-functions/Activation_Functions.py @@ -64,7 +64,7 @@ def set_seed(seed): # Additionally, some operations on a GPU are implemented stochastic for efficiency # We want to ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False # Fetching the device that will be used throughout this notebook diff --git a/course_UvA-DL/03-initialization-and-optimization/.meta.yml b/course_UvA-DL/03-initialization-and-optimization/.meta.yml index 6e79e150f..82961aea1 100644 --- a/course_UvA-DL/03-initialization-and-optimization/.meta.yml +++ b/course_UvA-DL/03-initialization-and-optimization/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 3: Initialization and Optimization" author: Phillip Lippe created: 2021-08-27 -updated: 2021-11-29 +updated: 2023-01-04 license: CC BY-SA tags: - Image diff --git a/course_UvA-DL/03-initialization-and-optimization/Initialization_and_Optimization.py b/course_UvA-DL/03-initialization-and-optimization/Initialization_and_Optimization.py index fdf27edbc..b653153f1 100644 --- a/course_UvA-DL/03-initialization-and-optimization/Initialization_and_Optimization.py +++ b/course_UvA-DL/03-initialization-and-optimization/Initialization_and_Optimization.py @@ -47,7 +47,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False # Fetching the device that will be used throughout this notebook @@ -937,8 +937,8 @@ def pathological_curve_loss(w1, w2): def plot_curve( curve_fn, x_range=(-5, 5), y_range=(-5, 5), plot_3d=False, cmap=cm.viridis, title="Pathological curvature" ): - fig = plt.figure() - ax = fig.gca(projection="3d") if plot_3d else fig.gca() + _ = plt.figure() + ax = plt.axes(projection="3d") if plot_3d else plt.axes() 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) diff --git a/course_UvA-DL/04-inception-resnet-densenet/.meta.yaml b/course_UvA-DL/04-inception-resnet-densenet/.meta.yaml index 6c5fc5a64..06c537aa1 100644 --- a/course_UvA-DL/04-inception-resnet-densenet/.meta.yaml +++ b/course_UvA-DL/04-inception-resnet-densenet/.meta.yaml @@ -1,7 +1,7 @@ title: "Tutorial 4: Inception, ResNet and DenseNet" author: Phillip Lippe created: 2021-08-27 -updated: 2021-11-29 +updated: 2023-01-04 license: CC BY-SA tags: - Image @@ -18,5 +18,6 @@ requirements: - matplotlib - seaborn - tabulate + - pytorch-lightning>=1.8 accelerator: - GPU diff --git a/course_UvA-DL/04-inception-resnet-densenet/Inception_ResNet_DenseNet.py b/course_UvA-DL/04-inception-resnet-densenet/Inception_ResNet_DenseNet.py index 5420a9dbe..8e1f76f21 100644 --- a/course_UvA-DL/04-inception-resnet-densenet/Inception_ResNet_DenseNet.py +++ b/course_UvA-DL/04-inception-resnet-densenet/Inception_ResNet_DenseNet.py @@ -49,7 +49,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu") @@ -348,7 +348,8 @@ def train_model(model_name, save_name=None, **kwargs): trainer = pl.Trainer( default_root_dir=os.path.join(CHECKPOINT_PATH, save_name), # Where to save models # We run on a single GPU (if possible) - gpus=1 if str(device) == "cuda:0" else 0, + accelerator="gpu" if str(device).startswith("cuda") else "cpu", + devices=1, # How many epochs to train for if no patience is set max_epochs=180, callbacks=[ @@ -357,7 +358,7 @@ def train_model(model_name, save_name=None, **kwargs): ), # Save the best checkpoint based on the maximum val_acc recorded. Saves only weights and not optimizer LearningRateMonitor("epoch"), ], # Log learning rate every epoch - progress_bar_refresh_rate=1, + enable_progress_bar=True, ) # In case your notebook crashes due to the progress bar, consider increasing the refresh rate trainer.logger._log_graph = True # If True, we plot the computation graph in tensorboard trainer.logger._default_hp_metric = None # Optional logging argument that we don't need diff --git a/course_UvA-DL/05-transformers-and-MH-attention/.meta.yml b/course_UvA-DL/05-transformers-and-MH-attention/.meta.yml index ffd3f88c1..80b75e295 100644 --- a/course_UvA-DL/05-transformers-and-MH-attention/.meta.yml +++ b/course_UvA-DL/05-transformers-and-MH-attention/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 5: Transformers and Multi-Head Attention" author: Phillip Lippe created: 2021-06-30 -updated: 2021-11-29 +updated: 2023-01-04 license: CC BY-SA build: 0 tags: @@ -19,5 +19,6 @@ requirements: - torchvision - matplotlib - seaborn + - pytorch-lightning>=1.8 accelerator: - GPU diff --git a/course_UvA-DL/05-transformers-and-MH-attention/Transformers_MHAttention.py b/course_UvA-DL/05-transformers-and-MH-attention/Transformers_MHAttention.py index cca56f2ee..6a184384f 100644 --- a/course_UvA-DL/05-transformers-and-MH-attention/Transformers_MHAttention.py +++ b/course_UvA-DL/05-transformers-and-MH-attention/Transformers_MHAttention.py @@ -61,7 +61,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu") @@ -979,10 +979,11 @@ def train_reverse(**kwargs): trainer = pl.Trainer( default_root_dir=root_dir, callbacks=[ModelCheckpoint(save_weights_only=True, mode="max", monitor="val_acc")], - gpus=1 if str(device).startswith("cuda") else 0, + accelerator="gpu" if str(device).startswith("cuda") else "cpu", + devices=1, max_epochs=10, gradient_clip_val=5, - progress_bar_refresh_rate=1, + enable_progress_bar=True, ) trainer.logger._default_hp_metric = None # Optional logging argument that we don't need @@ -1439,10 +1440,11 @@ def train_anomaly(**kwargs): trainer = pl.Trainer( default_root_dir=root_dir, callbacks=[ModelCheckpoint(save_weights_only=True, mode="max", monitor="val_acc")], - gpus=1 if str(device).startswith("cuda") else 0, + accelerator="gpu" if str(device).startswith("cuda") else "cpu", + devices=1, max_epochs=100, gradient_clip_val=2, - progress_bar_refresh_rate=1, + enable_progress_bar=True, ) trainer.logger._default_hp_metric = None # Optional logging argument that we don't need diff --git a/course_UvA-DL/06-graph-neural-networks/.meta.yml b/course_UvA-DL/06-graph-neural-networks/.meta.yml index 080e06fc7..fc1dc3c66 100644 --- a/course_UvA-DL/06-graph-neural-networks/.meta.yml +++ b/course_UvA-DL/06-graph-neural-networks/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 6: Basics of Graph Neural Networks" author: Phillip Lippe created: 2021-06-07 -updated: 2021-12-04 +updated: 2023-01-04 license: CC BY-SA build: 0 tags: @@ -19,10 +19,11 @@ description: | The full list of tutorials can be found at https://uvadlc-notebooks.rtfd.io. requirements: - torch-scatter - - torch-sparse<0.6.13 + - torch-sparse - torch-cluster - torch-spline-conv - - torch-geometric==2.0.2 + - torch-geometric + - pytorch-lightning>=1.8 pip__find-link: # - https://pytorch-geometric.com/whl/torch-1.8.0+cu101.html - https://pytorch-geometric.com/whl/torch-%(TORCH_MAJOR_DOT_MINOR)s.0+%(DEVICE)s.html diff --git a/course_UvA-DL/06-graph-neural-networks/GNN_overview.py b/course_UvA-DL/06-graph-neural-networks/GNN_overview.py index 2f0d7c487..4e8bc83e7 100644 --- a/course_UvA-DL/06-graph-neural-networks/GNN_overview.py +++ b/course_UvA-DL/06-graph-neural-networks/GNN_overview.py @@ -39,7 +39,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False # %% [markdown] @@ -634,7 +634,7 @@ 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. @@ -651,9 +651,10 @@ def train_node_classifier(model_name, dataset, **model_kwargs): trainer = pl.Trainer( default_root_dir=root_dir, callbacks=[ModelCheckpoint(save_weights_only=True, mode="max", monitor="val_acc")], - gpus=AVAIL_GPUS, + accelerator="gpu" if AVAIL_GPUS > 0 else "cpu", + devices=max(1, 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 @@ -932,9 +933,10 @@ def train_graph_classifier(model_name, **model_kwargs): trainer = pl.Trainer( default_root_dir=root_dir, callbacks=[ModelCheckpoint(save_weights_only=True, mode="max", monitor="val_acc")], - gpus=AVAIL_GPUS, + accelerator="gpu" if AVAIL_GPUS > 0 else "cpu", + devices=max(1, AVAIL_GPUS), max_epochs=500, - progress_bar_refresh_rate=0, + enable_progress_bar=False, ) trainer.logger._default_hp_metric = None diff --git a/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml b/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml index a7f682590..ab105f312 100644 --- a/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml +++ b/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 7: Deep Energy-Based Generative Models" author: Phillip Lippe created: 2021-07-12 -updated: 2021-07-12 +updated: 2023-01-04 license: CC BY-SA build: 0 tags: @@ -22,6 +22,7 @@ requirements: - torchvision - matplotlib - tensorboard + - pytorch-lightning>=1.8 accelerator: - CPU - GPU diff --git a/course_UvA-DL/07-deep-energy-based-generative-models/Deep_Energy_Models.py b/course_UvA-DL/07-deep-energy-based-generative-models/Deep_Energy_Models.py index 2d29e6dfb..a43a468cd 100644 --- a/course_UvA-DL/07-deep-energy-based-generative-models/Deep_Energy_Models.py +++ b/course_UvA-DL/07-deep-energy-based-generative-models/Deep_Energy_Models.py @@ -44,7 +44,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu") @@ -640,7 +640,8 @@ def train_model(**kwargs): # Create a PyTorch Lightning trainer with the generation callback trainer = pl.Trainer( default_root_dir=os.path.join(CHECKPOINT_PATH, "MNIST"), - gpus=1 if str(device).startswith("cuda") else 0, + accelerator="gpu" if str(device).startswith("cuda") else "cpu", + devices=1, max_epochs=60, gradient_clip_val=0.1, callbacks=[ @@ -650,7 +651,7 @@ def train_model(**kwargs): OutlierCallback(), LearningRateMonitor("epoch"), ], - progress_bar_refresh_rate=1, + enable_progress_bar=True, ) # Check whether pretrained model exists. If yes, load it and skip training pretrained_filename = os.path.join(CHECKPOINT_PATH, "MNIST.ckpt") diff --git a/course_UvA-DL/08-deep-autoencoders/.meta.yml b/course_UvA-DL/08-deep-autoencoders/.meta.yml index f6029b206..ca54ef5a0 100644 --- a/course_UvA-DL/08-deep-autoencoders/.meta.yml +++ b/course_UvA-DL/08-deep-autoencoders/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 8: Deep Autoencoders" author: Phillip Lippe created: 2021-07-12 -updated: 2021-07-12 +updated: 2023-01-04 license: CC BY-SA build: 0 tags: @@ -22,6 +22,7 @@ requirements: - torchvision - matplotlib - seaborn + - pytorch-lightning>=1.8 accelerator: - CPU - GPU diff --git a/course_UvA-DL/08-deep-autoencoders/Deep_Autoencoders.py b/course_UvA-DL/08-deep-autoencoders/Deep_Autoencoders.py index 8a1bf840b..cbe9b9653 100644 --- a/course_UvA-DL/08-deep-autoencoders/Deep_Autoencoders.py +++ b/course_UvA-DL/08-deep-autoencoders/Deep_Autoencoders.py @@ -41,7 +41,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu") @@ -385,7 +385,8 @@ def train_cifar(latent_dim): # Create a PyTorch Lightning trainer with the generation callback trainer = pl.Trainer( default_root_dir=os.path.join(CHECKPOINT_PATH, "cifar10_%i" % latent_dim), - gpus=1 if str(device).startswith("cuda") else 0, + accelerator="gpu" if str(device).startswith("cuda") else "cpu", + devices=1, max_epochs=500, callbacks=[ ModelCheckpoint(save_weights_only=True), diff --git a/course_UvA-DL/09-normalizing-flows/.meta.yml b/course_UvA-DL/09-normalizing-flows/.meta.yml index ffa0437d0..cf386b0e6 100644 --- a/course_UvA-DL/09-normalizing-flows/.meta.yml +++ b/course_UvA-DL/09-normalizing-flows/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 9: Normalizing Flows for Image Modeling" author: Phillip Lippe created: 2021-06-07 -updated: 2021-06-16 +updated: 2023-01-04 license: CC BY-SA build: 0 tags: @@ -25,6 +25,7 @@ requirements: - matplotlib - seaborn - tabulate + - pytorch-lightning>=1.8 accelerator: - CPU - GPU diff --git a/course_UvA-DL/09-normalizing-flows/NF_image_modeling.py b/course_UvA-DL/09-normalizing-flows/NF_image_modeling.py index 253149d1b..860f25271 100644 --- a/course_UvA-DL/09-normalizing-flows/NF_image_modeling.py +++ b/course_UvA-DL/09-normalizing-flows/NF_image_modeling.py @@ -44,7 +44,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False # Fetching the device that will be used throughout this notebook @@ -490,7 +490,7 @@ def visualize_dequantization(quants, prior=None): # Prior over discrete values. If not given, a uniform is assumed if prior is None: prior = np.ones(quants, dtype=np.float32) / quants - prior = prior / prior.sum() * quants # In the following, we assume 1 for each value means uniform distribution + prior = prior / prior.sum() # Ensure proper categorical distribution inp = torch.arange(-4, 4, 0.01).view(-1, 1, 1, 1) # Possible continuous values we want to consider ldj = torch.zeros(inp.shape[0]) @@ -798,21 +798,24 @@ def forward(self, x): class LayerNormChannels(nn.Module): - def __init__(self, c_in): - """This module applies layer norm across channels in an image. - - Has been shown to work well with ResNet connections. - Args: - c_in: Number of channels of the input + def __init__(self, c_in, eps=1e-5): + """ + This module applies layer norm across channels in an image. + Inputs: + c_in - Number of channels of the input + eps - Small constant to stabilize std """ super().__init__() - self.layer_norm = nn.LayerNorm(c_in) + self.gamma = nn.Parameter(torch.ones(1, c_in, 1, 1)) + self.beta = nn.Parameter(torch.zeros(1, c_in, 1, 1)) + self.eps = eps def forward(self, x): - x = x.permute(0, 2, 3, 1) - x = self.layer_norm(x) - x = x.permute(0, 3, 1, 2) - return x + mean = x.mean(dim=1, keepdim=True) + var = x.var(dim=1, unbiased=False, keepdim=True) + y = (x - mean) / torch.sqrt(var + self.eps) + y = y * self.gamma + self.beta + return y class GatedConv(nn.Module): @@ -825,7 +828,8 @@ def __init__(self, c_in, c_hidden): """ super().__init__() self.net = nn.Sequential( - nn.Conv2d(c_in, c_hidden, kernel_size=3, padding=1), + ConcatELU(), + nn.Conv2d(2 * c_in, c_hidden, kernel_size=3, padding=1), ConcatELU(), nn.Conv2d(2 * c_hidden, 2 * c_in, kernel_size=1), ) @@ -918,7 +922,8 @@ def train_flow(flow, model_name="MNISTFlow"): # Create a PyTorch Lightning trainer trainer = pl.Trainer( default_root_dir=os.path.join(CHECKPOINT_PATH, model_name), - gpus=1 if torch.cuda.is_available() else 0, + accelerator="gpu" if str(device).startswith("cuda") else "cpu", + devices=1, max_epochs=200, gradient_clip_val=1.0, callbacks=[ diff --git a/course_UvA-DL/11-vision-transformer/.meta.yml b/course_UvA-DL/11-vision-transformer/.meta.yml index 22fdd1323..9be56a10e 100644 --- a/course_UvA-DL/11-vision-transformer/.meta.yml +++ b/course_UvA-DL/11-vision-transformer/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 11: Vision Transformers" author: Phillip Lippe created: 2021-08-21 -updated: 2021-08-21 +updated: 2023-01-04 license: CC BY-SA description: | In this tutorial, we will take a closer look at a recent new trend: Transformers for Computer Vision. @@ -17,6 +17,7 @@ requirements: - torchvision - matplotlib - seaborn + - pytorch-lightning>=1.8 accelerator: - CPU - GPU diff --git a/course_UvA-DL/11-vision-transformer/Vision_Transformer.py b/course_UvA-DL/11-vision-transformer/Vision_Transformer.py index 169cd9cc8..480115726 100644 --- a/course_UvA-DL/11-vision-transformer/Vision_Transformer.py +++ b/course_UvA-DL/11-vision-transformer/Vision_Transformer.py @@ -39,7 +39,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu") @@ -378,13 +378,14 @@ def test_step(self, batch, batch_idx): def train_model(**kwargs): trainer = pl.Trainer( default_root_dir=os.path.join(CHECKPOINT_PATH, "ViT"), - gpus=1 if str(device) == "cuda:0" else 0, + accelerator="gpu" if str(device).startswith("cuda") else "cpu", + devices=1, max_epochs=180, callbacks=[ ModelCheckpoint(save_weights_only=True, mode="max", monitor="val_acc"), LearningRateMonitor("epoch"), ], - progress_bar_refresh_rate=1, + enable_progress_bar=True, ) trainer.logger._log_graph = True # If True, we plot the computation graph in tensorboard trainer.logger._default_hp_metric = None # Optional logging argument that we don't need diff --git a/course_UvA-DL/12-meta-learning/.meta.yml b/course_UvA-DL/12-meta-learning/.meta.yml index d5257ab16..7b640478f 100644 --- a/course_UvA-DL/12-meta-learning/.meta.yml +++ b/course_UvA-DL/12-meta-learning/.meta.yml @@ -1,7 +1,7 @@ title: "Tutorial 12: Meta-Learning - Learning to Learn" author: Phillip Lippe created: 2021-08-21 -updated: 2021-08-21 +updated: 2023-01-04 license: CC BY-SA tags: - Few-shot-learning @@ -23,6 +23,7 @@ requirements: - torchvision - matplotlib - seaborn + - pytorch-lightning>=1.8 accelerator: - CPU - GPU diff --git a/course_UvA-DL/12-meta-learning/Meta_Learning.py b/course_UvA-DL/12-meta-learning/Meta_Learning.py index 1ec243525..0cc1273f5 100644 --- a/course_UvA-DL/12-meta-learning/Meta_Learning.py +++ b/course_UvA-DL/12-meta-learning/Meta_Learning.py @@ -60,7 +60,7 @@ pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility -torch.backends.cudnn.determinstic = True +torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu") @@ -555,13 +555,14 @@ def validation_step(self, batch, batch_idx): def train_model(model_class, train_loader, val_loader, **kwargs): trainer = pl.Trainer( default_root_dir=os.path.join(CHECKPOINT_PATH, model_class.__name__), - gpus=1 if str(device) == "cuda:0" else 0, + accelerator="gpu" if str(device).startswith("cuda") else "cpu", + devices=1, max_epochs=200, callbacks=[ ModelCheckpoint(save_weights_only=True, mode="max", monitor="val_acc"), LearningRateMonitor("epoch"), ], - progress_bar_refresh_rate=0, + enable_progress_bar=False, ) trainer.logger._default_hp_metric = None