Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab VeloxTrend Ultrarix Capital Partners Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Our 15 AI experts built the most comprehensive, practical, 90+ lesson courses to master AI Engineering - we have pathways for any experience at Towards AI Academy. Cohorts still open - use COHORT10 for 10% off.

Publication

Visual Representation of Matrix and Vector Operations and implementation in NumPy, Torch, and Tensor
Deep Learning

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.

Visual Representation of Matrix and Vector Operations and implementation in NumPy, Torch, and Tensor
Excerpts

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

Scalar, 1-D, 2-D arrays

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

2-D Vector Array

2-D Array

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

4. Generating Data

Zeros and Ones
Diagonal & Same element fill

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

Draw random samples from the Normal distribution

Normal Dist’n Bell Curve
Samples were drawn from Normal Dist’n

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

Draw samples from the uniform distribution

Uniform Dist’n Curve
Samples were drawn from Uniform Dist’n

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

Sum and Subtract operations
multiply and divide operations

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

9. Dot Product

Dot Product

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

10. Matrix Multiplication

Matrix Multiplication

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

11. Indexing and Slicing (2-D)

Indexing and Slicing

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

12. Indexing and Slicing (2-D — Matrix)

Matrix Slicing

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

13. Reshaping and Transpose axes

Reshape & Transpose

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

14. Concatenation

Matrix Concatenation

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

15. Summing across axes

Axes — Sum

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

16. Mean across axes

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

17. Dimension Expansion & moving axes.

Concat and move axes

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

18. Max (Min) and Argmax :

Max for axis=0
Max for axis=1

Numpy Implementation:

TensorFlow Implementation:

Torch Implementation:

19. Slicing and Indexing (3-D Matrix)

3×3 Matrix and its indices
Upper-Left & Lower-Right
Middle Elements & Inverse Middle Element

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 meLinkedIn, GitHub, TwitterMedium

https://deepscopy.com/

`

Visit us DeepScopy

Connect with usTwitter, 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


Take our 90+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Towards AI has published Building LLMs for Production—our 470+ page guide to mastering LLMs with practical projects and expert insights!


Discover Your Dream AI Career at Towards AI Jobs

Towards AI has built a jobs board tailored specifically to Machine Learning and Data Science Jobs and Skills. Our software searches for live AI jobs each hour, labels and categorises them and makes them easily searchable. Explore over 40,000 live jobs today with Towards AI Jobs!

Note: Content contains the views of the contributing authors and not Towards AI.