TensorFlow前向传播

来源:互联网 发布:金星秀 知乎 编辑:程序博客网 时间:2024/05/16 14:45
import tensorflow as tf#特征向量x = tf.constant([[0.7, 0.9]])print(x)#参数weight1 = tf.constant([[0.2, 0.1, 0.4],                      [0.3, -0.5, 0.2]                      ])bias1 = tf.constant([[-0.5, 0.1, -0.1]])t = tf.constant([[0.09, 0.28, 0.36]])#参数weight2 = tf.constant([[0.6],                       [0.1],                       [-0.2]])bias2 = tf.constant([0.1])a = (tf.matmul(x, weight1) + bias1)y = (tf.matmul(t, weight2) + bias2)with tf.Session() as sess:    print(sess.run(a))    print('y=%g' % sess.run(y))

原创粉丝点击