誰訣別相思成疾莫問天涯
也莫問歸期
怎奈何無人瞭解 情斷之時
冷暖自知
《莫問歸期》
內容覆蓋:
- stack
- meshgrid
import tensorflow as tf
import os
import warnings
warnings.filterwarnings('ignore')
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
print(tf.__version__)
import matplotlib.pyplot as plt
2.0.0-alpha0 |
def meshgrid_compute(x):
z = tf.math.sin(x[...,0]) + tf.math.sin(x[...,1])
return z
x = tf.linspace(0., 2*3.14, 500)
y = x
# point_x: [500, 500]
# point_y: [500, 500]
point_x, point_y = tf.meshgrid(x, y)
# [500, 500, 2]
point_stack = tf.stack([point_x, point_y],axis=2)
z = meshgrid_compute(point_stack)
plt.contour(point_x, point_y, z)
plt.colorbar()
plt.show()