
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