Q:

Write a NumPy program to create an inner product of two arrays

0

Write a NumPy program to create an inner product of two arrays.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.arange(24).reshape((2,3,4))
print("Array x:")
print(x)
print("Array y:")
y = np.arange(4)
print(y)
print("Inner of x and y arrays:")
print(np.inner(x, y))

Sample Output:

Array x:                                                               
[[[ 0  1  2  3]                                                        
  [ 4  5  6  7]                                                        
  [ 8  9 10 11]]                                                       
                                                                       
 [[12 13 14 15]                                                        
  [16 17 18 19]                                                        
  [20 21 22 23]]]                                                      
Array y:                                                               
[0 1 2 3]                                                              
Inner of x and y arrays:                                               
[[ 14  38  62]                                                         
 [ 86 110 134]]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now