top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

NumPy Matrix Multiplication in Python

This article will show you how to use Python to execute element-wise matrix multiplication. Every element of the first matrix is multiplied by the corresponding element of the second matrix in element-wise matrix multiplication.




Both matrices should have the same dimensions when doing element-wise matrix multiplication. The size of the resultant matrix c of element-wise matrix multiplication a*b = c is always the same as that of a and b.


The NumPy library's np.multiply(x1, x2) method accepts two matrices as input, performs element-wise multiplication on them, and returns the resultant matrix as input.


To execute element-wise input, we must send the two matrices as input to the np.multiply() method. The example code below shows how to use Python's np.multiply() function to perform element-wise multiplication of two matrices.




# importing numpy library
import numpy as np

num1 = np.array([[17,46,33,7,12],[13,25,8,3,26]])
num2 = np.array([[5,26,11,17,22],[21,38,19,3,4]])

print(np.multiply(num1,num2))


Output:

[[  85 1196  363  119  264]  [ 273  950  152    9  104]] 

This is a very simple example of array multiplication using numpy library in python.

0 comments

Recent Posts

See All

COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page