Learn practical skills, build real-world projects, and advance your career

Open In Colab

# 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('1YYonnc_Czk7yGJXHM6ypcB8GtNXj0oU9')
|████████████████████████████████| 71kB 3.1MB/s eta 0:00:011 Building wheel for uuid (setup.py) ... done

5 Functions to Generate Tensors using Pytorch

Pytorch is essentially an open source machine learning framework developed by Facebook's AI research group. Pytorch uses dynamic computation unlike other deep learning frameworks (e.g. TensorFlow), making it flexible and easier to develop complex models. The use of classes, structures and loops make it easier to understand and use, compared to frameworks that use a different programming style.

This notebook has compiled 5 tensor functions that can be used to create tensors. The first two functions are based on simple ideas of creating and arranging a tensor, whereas the following three functions generate mathematical equivalent forms of tensors- complex, heavyside step and polar.

  • function 1: empty
  • function 2: arrange
  • function 3: complex
  • function 4: heavyside step
  • function 5: polar

Prerequisite: 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
# Import torch and other required modules
import torch