TensorFlow学习笔记(十九) 基本算术运算和Reduction归约计算
来源:互联网 发布:软件开发类招聘合同 编辑:程序博客网 时间:2024/06/05 11:34
基本运算,变量由tf.constant函数转化为1阶张量。然后计算;现在用tf.reduce_prod()和tf.reduce_sum()函数重新定义,当给定某个tensor张量作为输入时,这些函数会接收其所有分量,然后分别将它们相乘或相加。
1. 基本算术运算
tf.add(x, y, name=None)
求和
tf.sub(x, y, name=None)
减法
tf.multiply(x, y, name=None)
乘法
tf.div(x, y, name=None)
除法
tf.mod(x, y, name=None)
取模
tf.abs(x, name=None)
求绝对值
tf.neg(x, name=None)
取负 (y = -x).
tf.sign(x, name=None)
返回符号 y = sign(x) = -1 if x < 0; 0 if x == 0; 1 if x > 0.
tf.inv(x, name=None)
取反
tf.square(x, name=None)
计算平方 (y = x * x = x^2).
tf.round(x, name=None)
舍入最接近的整数 # ‘a’ is [0.9, 2.5, 2.3, -4.4] tf.round(a) ==> [ 1.0, 3.0, 2.0, -4.0 ]
tf.sqrt(x, name=None)
开根号 (y = \sqrt{x} = x^{1/2}).
tf.pow(x, y, name=None)
幂次方 # tensor ‘x’ is [[2, 2], [3, 3]] # tensor ‘y’ is [[8, 16], [2, 3]] tf.pow(x, y) ==> [[256, 65536], [9, 27]]
tf.exp(x, name=None)
计算e的次方
tf.log(x, name=None)
计算log,一个输入计算e的ln,两输入以第二输入为底
tf.maximum(x, y, name=None)
返回最大值 (x > y ? x : y)
tf.minimum(x, y, name=None)
返回最小值 (x < y ? x : y)
tf.cos(x, name=None)
三角函数cosine
tf.sin(x, name=None)
三角函数sine
tf.tan(x, name=None)
三角函数tan
tf.atan(x, name=None)
三角函数ctan
2. 归约计算(Reduction)
tf.reduce_sum(input_tensor, reduction_indices=None, keep_dims=False, name=None)
计算输入tensor元素的和,或者安照reduction_indices指定的轴进行求和 # ‘x’ is [[1, 1, 1]
# [1, 1, 1]] tf.reduce_sum(x) ==> 6 tf.reduce_sum(x, 0) ==> [2, 2, 2] tf.reduce_sum(x, 1) ==> [3, 3] tf.reduce_sum(x, 1, keep_dims=True) ==> [[3], [3]] tf.reduce_sum(x, [0, 1]) ==> 6
tf.reduce_prod(input_tensor, reduction_indices=None, keep_dims=False, name=None)
计算输入tensor元素的乘积,或者安照reduction_indices指定的轴进行求乘积
tf.reduce_min(input_tensor, reduction_indices=None, keep_dims=False, name=None)
求tensor中最小值
tf.reduce_max(input_tensor, reduction_indices=None, keep_dims=False, name=None)
求tensor中最大值
tf.reduce_mean(input_tensor, reduction_indices=None, keep_dims=False, name=None)
求tensor中平均值
tf.reduce_all(input_tensor, reduction_indices=None, keep_dims=False, name=None)
对tensor中各个元素求逻辑’与’ # ‘x’ is # [[True, True] # [False, False]] tf.reduce_all(x) ==> False tf.reduce_all(x, 0) ==> [False, False] tf.reduce_all(x, 1) ==> [True, False]
tf.reduce_any(input_tensor, reduction_indices=None, keep_dims=False, name=None)
对tensor中各个元素求逻辑’或’
tf.accumulate_n(inputs, shape=None, tensor_dtype=None, name=None)
计算一系列tensor的和 # tensor ‘a’ is [[1, 2], [3, 4]] # tensor b is [[5, 0], [0, 6]] tf.accumulate_n([a, b, a]) ==> [[7, 4], [6, 14]]
tf.cumsum(x, axis=0, exclusive=False, reverse=False, name=None)
求累积和 tf.cumsum([a, b, c]) ==> [a, a + b, a + b + c] tf.cumsum([a, b, c], exclusive=True) ==> [0, a, a + b] tf.cumsum([a, b, c], reverse=True) ==> [a + b + c, b + c, c] tf.cumsum([a, b, c], exclusive=True, reverse=True) ==> [b + c, c, 0]
- TensorFlow学习笔记(十九) 基本算术运算和Reduction归约计算
- CUDA学习(归约算法)
- Tensorflow学习笔记(2)-基本运算
- TensorFlow学习笔记2:基本运算
- C语法归约之表达式复合运算(4)
- 算术运算2(逻辑计算和复合运算)
- tensorflow学习笔记(十九):分布式Tensorflow
- tensorflow学习笔记(十九):分布式Tensorflow
- 计算几何学习笔记之基本运算
- C语法归约之数组和指针(1)
- tensorflow学习笔记(二十九):merge_all引发的血案
- pandas学习笔记-算术运算和数据对齐
- 第四节 面向计算编程-映射归约函数和推导式
- python 学习笔记之 算术运算符(除法)
- [TensorFlow学习笔记1]TensorFLow的基本概念和基本使用
- python tensorflow学习笔记(三)运算
- 编译原理的归约和推导
- MASM汇编语言笔记(三)数据传送和算术运算
- cocoapods最新使用方法
- Trepn Power Profiler工具的简单操作
- PAT-L1-008. 求整数段和
- mysql根据每天分组sql语句
- 将表中自增的列重新从1开始
- TensorFlow学习笔记(十九) 基本算术运算和Reduction归约计算
- IP地址最后一位自动增加为3位的EXCEL脚本
- select模型
- HTML5 表单新类型和新属性
- opencv 概述
- JavaScript使用Ajax传送JSON数据
- java连接redis
- 74HC573使用
- JVM-学习笔记