makedirs ( CHECKPOINT_PATH, exist_ok = True ) # For each file, check whether it already exists. # Github URL where saved models are stored for this tutorial base_url = "" # Files to download pretrained_files = # Create checkpoint path if it doesn't exist yet os. device ( "cuda:0" ) print ( "Using device", device ) benchmark = False # Fetching the device that will be used throughout this notebook device = torch. manual_seed_all ( seed ) set_seed ( 42 ) # 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. is_available (): # GPU operation have separate seed torch. get ( "PATH_CHECKPOINT", "saved_models/Activation_Functions/" ) # Function for setting the seed def set_seed ( seed ): np. get ( "PATH_DATASETS", "data/" ) # Path to the folder where the pretrained models are saved CHECKPOINT_PATH = os. # Path to the folder where the datasets are/should be downloaded (e.g. In case you are on Google Colab, it is recommended toĬhange the directories to start from the current directory (i.e. remove. The needed files will be automatically downloaded. The checkpoint path is the directory where we will store trained model weights and additional files. It is recommended to store all datasets from PyTorch in one joined directory to prevent duplicate downloads. The dataset path is the directory where we will download datasets used in the notebooks. All models here have been trained on an NVIDIA GTX1080Ti.Īdditionally, the following cell defines two paths: DATASET_PATH and CHECKPOINT_PATH. However, note that in contrast to the CPU, the same seed on different GPU architectures can give different results. This allows us to make our training reproducible. We will define a function to set a seed on all libraries we might interact with in this tutorial (here numpy and torch). set_matplotlib_formats ( "svg", "pdf" ) # For export sns. Import matplotlib_inline.backend_inline import numpy as np import seaborn as sns import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import as data import torchvision from torchvision import transforms from torchvision.datasets import FashionMNIST from tqdm.notebook import tqdm matplotlib_inline. Import json import math import os import urllib.request import warnings from urllib.error import HTTPError import matplotlib.pyplot as plt % matplotlib inline
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |