NumPy笔记:创建ndarray数组(zeros,ones,full,*_like,eye,identity
""" 创建ndarray数组(zeros,ones,full,*_like,eye,identity) """ import numpy as np print("zeros:", np.zeros([1, 3])) print("ones:", np.ones([1, 3])) print("full:", np.full([1, 3], 7)) print("ones_like", np.ones_like(np.zeros([1, 3]))) print("eye:", np.eye(3, 3, 0)) print("identity:", np.identity(3))
zeros: [[0. 0. 0.]] ones: [[1. 1. 1.]] full: [[7 7 7]] ones_like [[1. 1. 1.]] eye: [[1. 0. 0.] [0. 1. 0.] [0. 0. 1.]] identity: [[1. 0. 0.] [0. 1. 0.] [0. 0. 1.]]