np.arange()
row_idx = np.arange(0,rows)
col_idx = np.arange(0,cols)
参考链接:https://blog.csdn.net/qq_41550480/article/details/89390579
np.meshgrid()
import numpy as np
x = np.array([1,2,3]) #X_{x} = 3
y = np.array([4,5,6,7]) #X_{y} = 4
xv,yv = np.meshgrid( x , y )
print(xv)
print(yv)
[[1 2 3]
[1 2 3]
[1 2 3]
[1 2 3]]
[[4 4 4]
[5 5 5]
[6 6 6]
[7 7 7]]
Numpy.reshape()
除去order的部分,这个博客讲的比较清楚了,关于order参数见下面的示意图(二维),F是按列重排,C是按行重排。如果是多维,则理解为F从外侧的轴,C从最内侧的轴。
numpy.flatnonzero(arr)
概述
numpy.flatnonzero(arr)
- 作用: 先把矩阵拉平,然后返回拉平后矩阵中非0元素的index
- 举例:
参考链接:geeksForGeeks
新增维度: newaxis
x1 = x[np.newaxis, :]
References
[1] https://blog.csdn.net/xiaoqinting2015/article/details/69936952
[2] https://www.zhihu.com/question/295285045/answer/497930884