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: [email protected]
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 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

Take our 85+ 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!

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.

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 me β†’ LinkedIn, GitHub, Twitter,Β Medium

https://deepscopy.com/

`

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

Feedback ↓