Visual Representation of Matrix and Vector Operations and implementation in NumPy, Torch, and Tensor
Last Updated on January 6, 2023 by Editorial Team
Author(s): Balakrishnakumar V
Deep Learning
Visual Representation of Matrix and Vector Operations and implementations in NumPy, Torch, and TensorFlow.
Implementing rudimentary to advanced operations on deep learningβs fundamental units.
I am accustomed to creating new deep learning architectures for different problems, but which framework (Keras, Pytorch, TensorFlow) to choose is oftenΒ harder.
Since thereβs an uncertainty in it, itβs good to know the fundamental operations on those frameworkβs fundamental units (NumPy, Torch,Β Tensor).
In this post, I have performed a handful of the same operations across the 3 frameworks, also tried my hands on visualization for most ofΒ them.
This is a beginner-friendly post, so letβs getΒ started.
1. Installation
2. VersionΒ Check
3. Array Initialization ~ 1-D, 2-D,Β 3-D
Scalar and 1-DΒ Array
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
2-D VectorΒ Array
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
4. Generating Data
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
Draw random samples from the Normal distribution
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
Draw samples from the uniform distribution
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
6. Vector Arrangements
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
7. Data-TypeβββConversions
uint8/16/32/64 β β float8/16/32/64
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
8. Math Operations
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
9. DotΒ Product
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
10. Matrix Multiplication
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
11. Indexing and SlicingΒ (2-D)
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
12. Indexing and Slicing (2-DβββMatrix)
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
13. Reshaping and Transpose axes
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
14. Concatenation
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
15. Summing acrossΒ axes
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
16. Mean acrossΒ axes
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
17. Dimension Expansion & movingΒ axes.
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
18. Max (Min) and ArgmaxΒ :
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
19. Slicing and Indexing (3-DΒ Matrix)
Numpy Implementation:
TensorFlow Implementation:
Torch Implementation:
Due to visualization constraints, I skipped the operations on the higher dimension parts.
I hope I was able to provide some visual understanding to some of the fundamental operations along with your choice of deep learning framework and I will add more detailed operations shortly.
Check out the Notebook to find the above codes curated here βΒ Colab.
Until then, see you nextΒ time.
Article By:
BALAKRISHNAKUMAR V
Co-FounderβββDeepScopy (An AI-Based Medical ImagingΒ Startup)
Connect with me β LinkedIn, GitHub, Twitter,Β Medium
`
Visit us β DeepScopy
Connect with us β Twitter, LinkedIn, Medium
Visual Representation of Matrix and Vector Operations and implementation in NumPy, Torch, and Tensor was originally published in Towards AIβββMultidisciplinary Science Journal on Medium, where people are continuing the conversation by highlighting and responding to this story.
Published via Towards AI