首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >tf.nn.xw_plus_b

tf.nn.xw_plus_b

作者头像
周小董
发布2019-03-25 10:01:56
7430
发布2019-03-25 10:01:56
举报
文章被收录于专栏:python前行者python前行者

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。

参数:

  • x:2D Tensor。维度通常为:batch,in_units
  • weights:2D Tensor。维度通常为:in_units,out_units
  • biases:1D Tensor。维度为:out_units
  • name:操作的名称(可选)。如果未指定,则使用“xw_plus_b”。

返回:

  • 2-D Tensor用来计算matmul(x, weights) + biases。维度通常为:batch,out_units。

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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年03月18日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
批量计算
批量计算(BatchCompute,Batch)是为有大数据计算业务的企业、科研单位等提供高性价比且易用的计算服务。批量计算 Batch 可以根据用户提供的批处理规模,智能地管理作业和调动其所需的最佳资源。有了 Batch 的帮助,您可以将精力集中在如何分析和处理数据结果上。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档