numpy 中mgrid函数用法

import tensorflow as tf
import numpy as np

y,x = np.mgrid[0:38,0:38]

with tf.Session() as sess:
  
    print(x)
    print(y)

结果:

x

[[ 0  1  2 ... 35 36 37]
 [ 0  1  2 ... 35 36 37]
 [ 0  1  2 ... 35 36 37]
 ...
 [ 0  1  2 ... 35 36 37]
 [ 0  1  2 ... 35 36 37]

 [ 0  1  2 ... 35 36 37]]

y

[[ 0  0  0 ...  0  0  0]
 [ 1  1  1 ...  1  1  1]
 [ 2  2  2 ...  2  2  2]
 ...
 [35 35 35 ... 35 35 35]
 [36 36 36 ... 36 36 36]
 [37 37 37 ... 37 37 37]]

猜你喜欢

转载自blog.csdn.net/hanshihao1336295654/article/details/80471183