constants操作

import tensorflow as tf
a = tf.constant([2, 2], name='a')
b = tf.constant([[0, 1], [2, 3]], name='b')
x = tf.multiply(a, b, name='mul')
with tf.Session() as sess:
print(sess.run(x))
# >> [[0 2]
# [4 6]]
# 普通的元素数乘
常见 返回值类型 参数 说明
算数运算符
.add() Tensor x, y, name=N 加法(若x,y都为tensor, 数据类型需一致, 以下所有x,y都如此)
.subtract() Tensor 同add 减法
.multiply() Tensor 同add 元素级乘法
.scalar_mul() Tensor scalar, x 标量*tensor
.div() Tensor 同add 除法(结果dtype同x,y)
.divide() Tensor 同add 同Python除法 int8, int16 --> float32  int32, int64 --> float64
.truediv() Tensor 同add 同上
.floordiv() Tensor 同add 结果向下取整, 但结果dtype与输入保持一致
.realdiv() Tensor 同add 貌似仅支持浮点型除法
.truncatediv() Tensor 同add 结果截取整数部分, 貌似仅支持整数除法
.floor_div() Tensor 同add 没发现跟floordiv有什么不同
.truncatemod() Tensor 同add 取余, 跟truncatediv对应的取余
.floormod() Tensor 同add 取余, 跟floordiv对应的取余
.mod() Tensor 同add .floormod别名
.cross() Tensor a, b, name=N sum(a*out) = sum(b*out) = 0
基本数学函数(以下name参数全部省略)
.add_n() Tensor inputs list: [Tensor], 计算列表中所有tensor的加法运算
.abs() Tensor x 求绝对值
.negative() Tensor x 负, -x
.sign() Tensor x 符号, y = -1 if x < 0; 0 if x == 0 or tf.is_nan(x); 1 if x > 0
.reciprocal() Tensor x 倒数, 1/x
.square() Tensor x 平方, x**x
.round() Tensor x 四舍六入, 五取偶
.sqrt() Tensor x 开方, x**0.5
.rsqrt() Tensor x 开方的倒数, 1/x**0.5
.pow() Tensor x, y x**y
.exp() Tensor x e**x
.expm1() Tensor x e**x - 1
.log() Tensor x logx
.log1p() Tensor x log(1 + x)
.ceil Tensor x 向上取整
.floor() Tensor x 向下取整
.maximum() Tensor x, y 取x,y中的同位置最大值
.minimum() Tensor x, y 取x,y中的同位置最小值
.cos() Tensor x 余弦
.sin() Tensor x 正弦
.lbeta() Tensor x ???
.tan() Tensor x

正切

CS20Chapter2的更多相关文章

随机推荐

  1. megajson 高性能的json序列化、反序列化工具

    go 自带的 encoding/json 支持json的序列化和反序列化, 然而它是基于反射的,有下面几个缺点: 反射是性能差的代名词, 并且无法在编译时进行优化. 只有 Public 字段才可以,反 ...

  2. 20个网页设计师应该学习的CSS3经典教程实例

    CSS3技术离我们越近,我们也应该学习一些简单的CSS3技术了,而学习最基本的方法就是模仿,以及观看大师作品的案例.收集了20个基础教程,均是涉及到css3应用范围,值得你和我一起共同学习. Smoo ...

  3. window.event.srcElement与window.event.target 触发事件的元素 触发事件对象的获取,window.event与时间函数参数的event是同一个 事件对象

    判断事件触发的元素:     var tag = window.event.target || window.event.srcElement;    if (tag.tagName.toLowerC ...

  4. layui-table渲染不出来

    通过方法渲染 页面代码: <table id="tableList" lay-filter="clublist"></table> js ...

  5. MongoDB 排序文档

    sort() 方法 要在 MongoDB 中的文档进行排序,需要使用sort()方法. sort() 方法接受一个文档,其中包含的字段列表连同他们的排序顺序. 要指定排序顺序1和-1. 1用于升序排列 ...

  6. OpenCV实现基于傅里叶变换的旋转文本校正

    代码 先给出代码,再详细解释一下过程: #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp& ...

  7. VUE知识day3_vue-cli脚手架安装和webpack模板项目生成

    ue-cli 是一个官方发布 vue.js 项目脚手架,使用 vue-cli 可以快速创建 vue 项目. GitHub地址是:https://github.com/vuejs/vue-cli 一.安 ...

  8. oracle 找回DROP掉的表

    select * from pan ;   --有数据 drop table pan;        --删除表 select * from pan ;   --表或视图不存在 flashback t ...

  9. linux,强大的history命令

    如果你经常使用 Linux 命令行,那么使用 history(历史)命令可以有效地提升你的效率.本文将通过实例的方式向你介绍 history 命令的 15 个用法. 使用 HISTTIMEFORMAT ...

  10. Python学习---django多对多自定义第三方表180206

    案例一: # version: python3.2.5 # author: 'FTL1012' # time: 2018/2/6 16:25 from django.db import models ...