加载TensorFlow
import tensorflow as tf
输出版本号
print("Tensorflow Version: {}".format(tf.__version__))
Tensorflow Version: 1.14.0
进行两个矩阵的运算
# 来进行两个矩阵的运算
w = tf.Variable([[0.5, 1.0]])
x = tf.Variable([[2.0], [1.0]])
y = tf.matmul(w, x)
y
<tf.Tensor 'MatMul:0' shape=(1, 1) dtype=float32>
变量值显示
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
print(y.eval())
[[2.]]
初试化矩阵
# float32
tf.zeros([3, 4], tf.int32)
xx = tf.Variable([