# Jovian Commit Essentials
# Please retain and execute this cell without modifying the contents for `jovian.commit` to work
!pip install jovian --upgrade -q
import jovian
jovian.utils.colab.set_colab_file_id('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDY0MDI5NTQsIm5iZiI6MTYwNjQwMjk1NCwianRpIjoiYjczMWMzNDUtNDg5MC00M2VlLTk4YTgtOGU3MTk0NTk0MzcwIiwiZXhwIjoxNjEwMjkwOTU0LCJpZGVudGl0eSI6eyJpZCI6Mzg1NTMsInVzZXJuYW1lIjoiYWhtZWQtb3VsYWRhbWFyYSJ9LCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.zSmLiIQyHX3bmzU-QyBLE2cxk4O8Xido8Ov7fDZaH60')
Assignment Instructions (delete this cell before submission)
The objective of this assignment is to develop a solid understanding of PyTorch tensors. In this assignment you will:
Pick 5 interesting functions related to PyTorch tensors by reading the documentation,
Edit this starter template notebook to illustrate their usage and publish your notebook to Jovian using
jovian.commit
. Make sure to add proper explanations too, not just code.Submit the link to your published notebook on Jovian here: https://jovian.ai/learn/deep-learning-with-pytorch-zero-to-gans/assignment/assignment-1-all-about-torch-tensor .
(Optional) Write a blog post on Medium to accompany and showcase your Jupyter notebook. Embed cells from your notebook wherever necessary.
(Optional) Share your work with the community and exchange feedback with other participants
The recommended way to run this notebook is to click the "Run" button at the top of this page, and select "Run on Colab". Run
jovian.commit
regularly to save your progress.Try to give your notebook an interesting title e.g. "All about PyTorch tensor operations", "5 PyTorch functions you didn't know you needed", "A beginner's guide to Autograd in PyToch", "Interesting ways to create PyTorch tensors", "Trigonometic functions in PyTorch", "How to use PyTorch tensors for Linear Algebra" etc.
IMPORTANT NOTE: Make sure to submit a Jovian notebook link e.g. https://jovian.ai/aakashns/01-tensor-operations . Colab links will not be accepted.
Remove this cell containing instructions before making a submission or sharing your notebook, to make it more presentable.
Examples of Pytorch Functions
An short introduction about PyTorch and about the chosen functions.
- torch.clamp
- torch.max
- torch.dist
- torch.cat
- torch.mean
Before we begin, let's install and import PyTorch
# Uncomment and run the appropriate command for your operating system, if required
# Linux / Binder
!pip install numpy torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
# Windows
# !pip install numpy torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
# MacOS
# !pip install numpy torch torchvision torchaudio
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Requirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (1.18.5)
Collecting torch==1.7.0+cpu
Downloading https://download.pytorch.org/whl/cpu/torch-1.7.0%2Bcpu-cp37-cp37m-linux_x86_64.whl (159.3 MB)
|████████████████████████████████| 159.3 MB 3.7 kB/s eta 0:00:01
Requirement already satisfied: dataclasses in /opt/conda/lib/python3.7/site-packages (from torch==1.7.0+cpu) (0.6)
Requirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (1.18.5)
Requirement already satisfied: future in /opt/conda/lib/python3.7/site-packages (from torch==1.7.0+cpu) (0.18.2)
Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.7/site-packages (from torch==1.7.0+cpu) (3.7.4.1)
Collecting torchaudio==0.7.0
Downloading torchaudio-0.7.0-cp37-cp37m-manylinux1_x86_64.whl (7.6 MB)
|████████████████████████████████| 7.6 MB 3.0 MB/s eta 0:00:01
Collecting torchvision==0.8.1+cpu
Downloading https://download.pytorch.org/whl/cpu/torchvision-0.8.1%2Bcpu-cp37-cp37m-linux_x86_64.whl (11.8 MB)
|████████████████████████████████| 11.8 MB 38.4 MB/s eta 0:00:01
Requirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (1.18.5)
Requirement already satisfied: pillow>=4.1.1 in /opt/conda/lib/python3.7/site-packages (from torchvision==0.8.1+cpu) (8.0.1)
Installing collected packages: torch, torchvision, torchaudio
Attempting uninstall: torch
Found existing installation: torch 1.7.0
Uninstalling torch-1.7.0:
Successfully uninstalled torch-1.7.0
Attempting uninstall: torchvision
Found existing installation: torchvision 0.8.1
Uninstalling torchvision-0.8.1:
Successfully uninstalled torchvision-0.8.1
Attempting uninstall: torchaudio
Found existing installation: torchaudio 0.7.0a0+ac17b64
Uninstalling torchaudio-0.7.0a0+ac17b64:
Successfully uninstalled torchaudio-0.7.0a0+ac17b64
Successfully installed torch-1.7.0+cpu torchaudio-0.7.0 torchvision-0.8.1+cpu
# Import torch and other required modules
import torch