cupy.indices#
- cupy.indices(dimensions, dtype=<class 'int'>)[source]#
返回表示网格索引的数组。
计算一个数组,其中子数组包含索引值 0,1,...,这些值仅沿相应轴变化。
- 参数:
dimensions – 网格的形状。
dtype – 数据类型说明符。默认为 int。
- 返回:
网格索引数组,
grid.shape = (len(dimensions),) + tuple(dimensions)
。- 返回类型:
示例
>>> grid = cupy.indices((2, 3)) >>> grid.shape (2, 2, 3) >>> grid[0] # row indices array([[0, 0, 0], [1, 1, 1]]) >>> grid[1] # column indices array([[0, 1, 2], [0, 1, 2]])
另请参阅