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))
TensorFlow前向传播
最新推荐文章于 2024-05-02 15:02:51 发布