np.zeros_like()
输入为矩阵x
输出为形状和x一致的矩阵,其元素全部为0
>>> import numpy as np >>> a=np.arange(12) >>> a=a.reshape(2,2,3) >>> a array([[[ 0, 1, 2], [ 3, 4, 5]], [[ 6, 7, 8], [ 9, 10, 11]]]) >>> b=np.zeros_like(a) >>> b array([[[0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0]]])