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. DButils分析

    package com.ldf.utils; import java.sql.Connection; public class DBUtils { private static String driv ...

  2. Groovy中的操作符重载

    操作者 方法 a + b a.plus(b)中 a - b a.minus(b)中 a * b a.multiply(b)中 a ** b a.power(b)中 a / b a.div(b)中 a ...

  3. Excel2010条件格式的位置

    以下是excel2010的条件格式设置方法(英文版) 具体使用方法可以参考 http://office.microsoft.com/zh-cn/excel-help/HA102809768.aspx

  4. Redis ,Memcached ,Mongodb 对比

    memcached: 1.适合做内存缓存,对可靠性没有要求,不支持持久化:速度快.并发高.2.支持的数据结构单一,只支持Key-value,3.value最大支持1M3.在传统tomcat 部署war ...

  5. sql:PostgreSQL9.3 Using RETURNS TABLE vs. OUT parameters

    http://www.postgresonline.com/journal/archives/201-Using-RETURNS-TABLE-vs.-OUT-parameters.html http: ...

  6. python,tensorflow,CNN实现mnist数据集的训练与验证正确率

    1.工程目录 2.导入data和input_data.py 链接:https://pan.baidu.com/s/1EBNyNurBXWeJVyhNeVnmnA 提取码:4nnl 3.CNN.py i ...

  7. Two references point to the same heap memory

    Phone类 package com.itheima_03; /* * 手机类 */ public class Phone { String brand; int price; String colo ...

  8. ruby-程序员最好的朋友

    ruby一门开源的动态编程语言,注重简洁和效率.Ruby 的句法优雅,读起来自然,写起来舒适. 介绍 这是个不会超过20分钟的 Ruby 简介.阅读前请您先将 Ruby 安装好.(如果您还没有安装Ru ...

  9. 安卓性能优化之清除Handler的Message和Runnable

    安卓性能优化之清除Handler的Message和Runnable Handler是由系统所提供的一种异步消息处理的常用方式,一般情况下不会发生内存泄露. 但既然是调优,当在A_Activity中使用 ...

  10. Java软件编码规范要求

    1.一个类对应一个文件,文件名与类名保持一致 虽然一个“.java”源文件可以有多个类(不是内部类),但是不提倡那么写.