栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

tensorflow常用函数(tensorflow使用)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

tensorflow常用函数(tensorflow使用)

利用tensorflow计算出导数时,其类型为列表的tensor,与其他单个tensor进行运算时,其结果的维度会发生变化,这里对其进行总结。

1. 网络

网络输入:x (numpy数组)

网络输出:u

主要运算:图

输出:

u: Tensor("strided_slice_72:0", shape=(?, 1), dtype=float32)

u_x: []

        为输出u关于输入x的一阶导

u_x2: []

        为输出u关于输入x的二阶导

​​​​​​​

2. 相互之间运算1:

u_x * u_x: 报错,同为装有tensorflow的列表

u_x[0] * u_x[0]: Tensor("mul_1346:0", shape=(?, 1), dtype=float32)

u * u: Tensor("mul_1347:0", shape=(?, 1), dtype=float32)

u * u_r: Tensor("mul_1348:0", shape=(1, ?, 1), dtype=float32)

u *u_r[0]: Tensor("mul_1349:0", shape=(?, 1), dtype=float32)

3. 相互之间运算2:

x: Tensor("x:0", shape=(?, 1), dtype=float32)

           为placeholder的数组

xs: Tensor("xs:0", shape=(), dtype=float32_ref)

           为tf.Variable(0.3, name="rs")

u / x: Tensor("truediv_55:0", shape=(?, 1), dtype=float32)

u / xs: Tensor("truediv_56:0", shape=(?, 1), dtype=float32)

u_x / x: Tensor("truediv_57:0", shape=(1, ?, 1), dtype=float32)

u_x / xs: Tensor("truediv_58:0", shape=(1, ?, 1), dtype=float32)

u_x[0] / x: Tensor("truediv_59:0", shape=(?, 1), dtype=float32)

u_x[0] / xs: Tensor("truediv_60:0", shape=(?, 1), dtype=float32)

4. 总结

①Tensor里第一个属性:add、sub由计算的最后一步操作决定;

②包含求导项(列表的tensor)时,维度会变成(1, ?, 1);

如果想让最终的tensoorflow无列表,则需要将列表tensor都取[0];

③列表型相加时,按照列表加法,会将两个列表组合起来。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/772866.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号