[jovian] Detected Colab notebook...
[jovian] Please enter your API key ( from https://jovian.ai/ ):
API KEY:
This post is the first in a series of tutorials on building deep learning models with PyTorch, an open source neural networks library developed and maintained by Facebook. Check out the full series:
This series attempts to make PyTorch a bit more approachable for people starting out with deep learning and neural networks. In this notebook, we’ll cover the basic building blocks of PyTorch models: tensors and gradients.
This tutorial takes a code-first approach towards learning PyTorch, and you should try to follow along by running and experimenting with the code yourself. The easiest way to start executing this notebook is to click the "Run" button at the top of this page, and select "Run on Binder". This will run the notebook on mybinder.org, a free online service for running Jupyter notebooks.
NOTE: If you're running this notebook on Binder, please skip ahead to the next section.
We'll use the Anaconda distribution of Python to install libraries and manage virtual environments. For interactive coding and experimentation, we'll use Jupyter notebooks. All the tutorials in this series are available as Jupyter notebooks hosted on Jovian.ml: a sharing and collaboration platform for Jupyter notebooks & machine learning experiments.
Jovian.ml makes it easy to share Jupyter notebooks on the cloud by running a single command directly within Jupyter. It also captures the Python environment and libraries required to run your notebook, so anyone (including you) can reproduce your work.
Here's what you need to do to get started:
Install Anaconda by following the instructions given here. You might also need to add Anaconda binaries to your system PATH to be able to run the conda
command line tool.
Install the jovian
Python library by the running the following command (without the $
) on your Mac/Linux terminal or Windows command prompt:
$ pip install jovian --upgrade
jovian clone
command:$ jovian clone aakashns/01-pytorch-basics
(You can copy this command to clipboard by clicking the 'Clone' button at the top of this page on Jovian.ml)
Running the clone command creates a directory 01-pytorch-basics
containing a Jupyter notebook and an Anaconda environment file.
$ ls 01-pytorch-basics
01-pytorch-basics.ipynb environment.yml
jovian
:$ cd 01-pytorch-basics
$ jovian install
jovian install
reads the environment.yml
file, identifies the right dependencies for your operating system, creates a virtual environment with the given name (01-pytorch-basics
by default) and installs all the required libraries inside the environment, to avoid modifying your system-wide installation of Python. It uses conda
internally. If you face issues with jovian install
, try running conda env update
instead.
$ conda activate 01-pytorch-basics
For older installations of conda
, you might need to run the command: source activate 01-pytorch-basics
.
$ jupyter notebook
01-pytorch-basics.ipynb
to open it and run the code. If you want to type out the code yourself, you can also create a new notebook using the 'New' button.We begin by importing PyTorch:
jovian.commit()
# Uncomment the command below if PyTorch is not installed
# !conda install pytorch cpuonly -c pytorch -y