1, sample code:
import tensorflow as tf
a = 3
#创建变量
w = tf.Variable([[0.6,1.2]])#创建行向量
x = tf.Variable([[2.1],[4.2]]) #创建列向量
y = tf.matmul(w, x) #矩阵相乘
init_op = tf.global_variables_initializer()# 初始化
with tf.Session() as sess:
sess.run(init_op)
print(y.eval()) #输出y的值
2, code analysis:
TensorFlow call the corresponding function block (the API), needs to be converted into a variable format supported TensorFlow (tf.Variable), using tf.Variable, the corresponding memory region is created variables (no specific value), in the TensorFlow need for further call tf.global_variables_initializer, the global initialization variables (complete assignment), all of the above needs to be done in the calculation of FIG tf.Session defined.