1 import numpy as np 2 3 arr1 = np.array([[0, 1], [1, 2]]) # shape(2, 2) 4 arr2 = np.array([1, 1]) # shape(2, )——>(1, 2)——>[[1, 1]] 5 print("arr1: \n", arr1) 6 print("arr2: \n", arr2) 7 print("arr1+arr2: \n", arr1+arr2) 8 9 arr1 = np.array([[1, 2, 3], [4, 5, 6]]) # shape(2, 3) 10 arr2 = np.array([[1, 1], [1, 1], [1, 1]]) # shape(3, 2) 11 arr3 = np.array([[1], [1]]) # shape(2, 1) 12 13 print("arr1: \n", arr1) 14 print("arr2: \n", arr2) 15 print("arr2: \n", arr3) 16 # print("arr1+arr2: \n", arr1+arr2) 17 print("arr1+arr3: \n", arr1+arr3)
原文地址:https://www.cnblogs.com/Tree0108/p/12115528.html
时间: 2024-10-03 06:41:31