tf.nn.xw_plus_b函数
tf.nn.xw_plus_b(
x,
weights,
biases,
name=None
)
定义在:tensorflow/python/ops/nn_ops.py。 计算matmul(x, weights) + biases。
参数:
返回:
tf.nn.xw_plus_b((x, weights) + biases)
相当于tf.matmul(x, weights) + biases
#-*-coding:utf8-*-
import tensorflow as tf
x=[[1, 2, 3],[4, 5, 6]]
w=[[ 7, 8],[ 9, 10],[11, 12]]
b=[[3,3],[3,3]]
result1=tf.nn.xw_plus_b(x,w,[3,3])
result2=tf.matmul(x, w) + b
init_op = tf.initialize_all_variables()
with tf.Session() as sess:
# Run the init operation.
sess.run(init_op)
print(sess.run(result1))
print(sess.run(result2))
输出:
[[ 61 67]
[142 157]]
[[ 61 67]
[142 157]]
参考:https://www.w3cschool.cn/tensorflow_python/tf_nn_xw_plus_b.html https://blog.csdn.net/ddy_sweety/article/details/80679077