import numpy as np
a=np.array([[1,2],[3,4]])
b=np.array([[[7,8],[9,10]],
[[5,6],[7,8]]])
c=b-a
print(c)
print(b.shape)
print(c.shape)
d=b+a
print(d)
print(d.shape)
The result of running is:
[[[6 6]
[6 6]][[4 4]
[4 4]]]
(2, 2, 2)
(2, 2, 2)
[[[ 8 10]
[12 14]][[ 6 8]
[10 12]]]
(2, 2, 2)
It can be seen that adding tensors is similar to expanding low-dimensional tensors into high-dimensional tensors, adding and subtracting. Multiplication and division estimates are similar. thank you all