In [1]:
import numpy as np
In [2]:
a = b = np.arange(3)
print(a)
In [3]:
print(a.shape)
In [4]:
print(a * b)
In [5]:
print(np.multiply(a, b))
In [6]:
a_1_3 = a.reshape(1, 3)
print(a_1_3)
In [7]:
print(a_1_3.shape)
In [8]:
b_3_1 = b.reshape(3, 1)
print(b_3_1)
In [9]:
print(b_3_1.shape)
In [10]:
print(a_1_3 * b_3_1)
In [11]:
print(np.multiply(a_1_3, b_3_1))
In [12]:
print(a * b_3_1)
In [13]:
print(np.multiply(a, b_3_1))
In [14]:
print(a_1_3 @ b_3_1)
In [15]:
print(np.matmul(a_1_3, b_3_1))
In [16]:
print(np.dot(a_1_3, b_3_1))
In [17]:
print(type(a_1_3 @ b_3_1))
In [18]:
print((a_1_3 @ b_3_1).shape)
In [19]:
print(a_1_3 @ b)
In [20]:
print(np.matmul(a_1_3, b))
In [21]:
print(np.dot(a_1_3, b))
In [22]:
print(type(a_1_3 @ b))
In [23]:
print((a_1_3 @ b).shape)
In [24]:
print(a @ b)
In [25]:
print(np.matmul(a, b))
In [26]:
print(np.dot(a, b))
In [27]:
print(type(a @ b))
In [28]:
a = np.arange(6).reshape(2, 3)
print(a)
In [29]:
b = np.arange(2).reshape(1, 2)
print(b)
In [30]:
# print(a @ b)
# ValueError: shapes (2,3) and (1,2) not aligned: 3 (dim 1) != 1 (dim 0)
In [31]:
print(np.tile(b, (3, 1)))
In [32]:
print(a @ np.tile(b, (3, 1)))