import tensorflow as tf
#tensorflow eager调试模式关键导入如下两行
import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()
#使得LSTM模型循环使用
tf.reset_default_graph()
import numpy as np
############example1
np_x = np.array(2., dtype=np.float32)
x = tf.constant(np_x)
py_y = 3.
y = tf.constant(py_y)
z = x + y + 1
print(z)
print(z.numpy())
############example2
x=[[2,2],[3,3]]
m=tf.matmul(x,x)
print(m)
#输出
分别为
tf.Tensor(6.0, shape=(), dtype=float32)
6.0
tf.Tensor(
[[10 10]
[15 15]], shape=(2, 2), dtype=int32)