MIT Logo

Earth Signals and Systems Group

Informatics and Intelligent Systems for Earth, Atmospheric, and Planetary Science

Introduction to Pytorch

On Friday 02/07 we will go together through a Pytorch tutorial to learn the basics, and to provide you with a template from which you can start coding and training your own Pytorch models. The tutorial is written in a jupyter notebook, that you can download at:

https://www.dropbox.com/s/s2i4qpq5z5itqrb/intro_pytorch_MNIsT.ipynb?dl=0

If you are new to Python, I recommand you install Anaconda (https://www.anaconda.com/distribution/, choose the right OS!), which is a Python environment manager. Windows users should be provided with an Anaconda terminal after installing anaconda. Once Anaconda is installed, you can create a new environment dedicated to the tutorial (recommanded) by running:

conda create -n tuto_pytorch python=3.7

You now need to activate this environment:

conda activate tuto_pytorch

We need to provide you with the packages required by the tutorial, starting with pytorch itself (cf. https://pytorch.org/). Here is a command line to download torch and torchvision without cuda (no GPU support):

conda install pytorch torchvision cpuonly -c pytorch

Since we are going to plot data and results, we need the plotting library matplotlib:

conda install matplotlib

Finally, install jupyterlab:

conda install -c conda-forge jupyterlab

You are all set for running the tutorial! Open a terminal from the directory where the jupyter notebook is located, and run:

jupyter notebook intro_pytorch_MNIsT.ipynb

To make sure you have all the necessary packages, run the first cell of the notebook and see if you get an error.