mindspore.numpy.ogrid
- mindspore.numpy.ogrid()
- 返回一个稀疏矩阵 - NdGrid实例,其中- sparse=True。 输出数组的维度和数量等于索引维度的数量。如果- step不是一个复数,则- stop不包括在内。然而,如果- step是复数(例如5j),那么它的整数部分被解释为指定要在- start和- stop之间创建的点的数量,其中- stop包括在内。- 说明 - 在graph模式下不受支持。与Numpy不同,如果 - step是一个带有实数分量的复数,则- step被处理为等效于- int(abs(step))。- 异常:
- TypeError - 如果切片索引不是整数。 
 
- 支持平台:
- Ascend- GPU- CPU
 - 样例: - >>> import mindspore.numpy as np >>> output = np.ogrid[0:5,0:5] >>> print(output) [Tensor(shape=[5, 1], dtype=Int32, value= [[0], [1], [2], [3], [4]]), Tensor(shape=[1, 5], dtype=Int32, value= [[0, 1, 2, 3, 4]])] >>> output = ogrid[-1:1:5j] >>> print(output) [-1. -0.5 0. 0.5 1. ]