""" 多维数组 """ import numpy as np print("--------------多维数组----------------") data = np.array(3) data1 = np.array([1, 2, 3, 4, 5, 6]) data2 = np.array([[1, 2, 3, 4, 5, 6]]) data3 = np.array([[[1, 2, 3, 4, 5, 6]]], dtype=float) print("标量:", data, data.shape, type(data), data.dtype) print("数组:", data1, data1.shape, type(data1), data1.dtype) print("矩阵:", data2, data2.shape, type(data2), data2.dtype) print("张量:", data3, data3.shape, type(data3), data3.dtype)
--------------多维数组---------------- 标量: 3 () <class 'numpy.ndarray'> int32 数组: [1 2 3 4 5 6] (6,) <class 'numpy.ndarray'> int32 矩阵: [[1 2 3 4 5 6]] (1, 6) <class 'numpy.ndarray'> int32 张量: [[[1. 2. 3. 4. 5. 6.]]] (1, 1, 6) <class 'numpy.ndarray'> float64