『TensorFlow』函数查询列表_数值计算
基本算术运算
操作 | 描述 |
---|---|
tf.add(x, y, name=None) | 求和 |
tf.sub(x, y, name=None) | 减法 |
tf.mul(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 |
矩阵运算
操作 | 描述 |
---|---|
tf.diag(diagonal, name=None) | 返回一个给定对角值的对角tensor # ‘diagonal’ is [1, 2, 3, 4] tf.diag(diagonal) ==> [[1, 0, 0, 0] [0, 2, 0, 0] [0, 0, 3, 0] [0, 0, 0, 4]] |
tf.diag_part(input, name=None) | 功能与上面相反 |
tf.trace(x, name=None) | 求一个2维tensor足迹,即对角值diagonal之和 |
tf.transpose(a, perm=None, name=’transpose’) | 调换tensor的维度顺序 按照列表perm的维度排列调换tensor顺序, 如为定义,则perm为(n-1…0) # ‘x’ is [[1 2 3],[4 5 6]] tf.transpose(x) ==> [[1 4], [2 5],[3 6]] # Equivalently tf.transpose(x, perm=[1, 0]) ==> [[1 4],[2 5], [3 6]] |
tf.matmul(a, b, transpose_a=False, transpose_b=False, a_is_sparse=False, b_is_sparse=False, name=None) |
矩阵相乘 |
tf.matrix_determinant(input, name=None) | 返回方阵的行列式 |
tf.matrix_inverse(input, adjoint=None, name=None) | 求方阵的逆矩阵,adjoint为True时,计算输入共轭矩阵的逆矩阵 |
tf.cholesky(input, name=None) | 对输入方阵cholesky分解, 即把一个对称正定的矩阵表示成一个下三角矩阵L和其转置的乘积的分解A=LL^T |
tf.matrix_solve(matrix, rhs, adjoint=None, name=None) | 求解tf.matrix_solve(matrix, rhs, adjoint=None, name=None) matrix为方阵shape为[M,M],rhs的shape为[M,K],output为[M,K] |
复数操作
操作 | 描述 |
---|---|
tf.complex(real, imag, name=None) | 将两实数转换为复数形式 # tensor ‘real’ is [2.25, 3.25] # tensor imag is [4.75, 5.75]tf.complex(real, imag) ==> [[2.25 + 4.75j], [3.25 + 5.75j]] |
tf.complex_abs(x, name=None) | 计算复数的绝对值,即长度。 # tensor ‘x’ is [[-2.25 + 4.75j], [-3.25 + 5.75j]] tf.complex_abs(x) ==> [5.25594902, 6.60492229] |
tf.conj(input, name=None) | 计算共轭复数 |
tf.imag(input, name=None) tf.real(input, name=None) |
提取复数的虚部和实部 |
tf.fft(input, name=None) | 计算一维的离散傅里叶变换,输入数据类型为complex64 |
归约计算(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] |
序列比较与索引提取(Sequence Comparison and Indexing)
操作 | 描述 |
---|---|
tf.argmin(input, dimension, name=None) | 返回input最小值的索引index |
tf.argmax(input, dimension, name=None) | 返回input最大值的索引index |
tf.listdiff(x, y, name=None) | 返回x,y中不同值的索引 |
tf.where(input, name=None) | 返回bool型tensor中为True的位置 # ‘input’ tensor is #[[True, False] #[True, False]] # ‘input’ 有两个’True’,那么输出两个坐标值. # ‘input’的rank为2, 所以每个坐标为具有两个维度. where(input) ==> [[0, 0], [1, 0]] |
tf.unique(x, name=None) | 返回一个元组tuple(y,idx),y为x的列表的唯一化数据列表, idx为x数据对应y元素的index # tensor ‘x’ is [1, 1, 2, 4, 4, 4, 7, 8, 8] y, idx = unique(x) y ==> [1, 2, 4, 7, 8] idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4] |
tf.invert_permutation(x, name=None) | 置换x数据与索引的关系 # tensor x is [3, 4, 0, 2, 1]invert_permutation(x) ==> [2, 4, 3, 0, 1] |
『TensorFlow』函数查询列表_数值计算的更多相关文章
- 『TensorFlow』函数查询列表_神经网络相关
tf.Graph 操作 描述 class tf.Graph tensorflow中的计算以图数据流的方式表示一个图包含一系列表示计算单元的操作对象以及在图中流动的数据单元以tensor对象表现 tf. ...
- 『TensorFlow』函数查询列表_张量属性调整
数据类型转换Casting 操作 描述 tf.string_to_number(string_tensor, out_type=None, name=None) 字符串转为数字 tf.to_doubl ...
- 『TensorFlow』第七弹_保存&载入会话_霸王回马
首更: 由于TensorFlow的奇怪形式,所以载入保存的是sess,把会话中当前激活的变量保存下来,所以必须保证(其他网络也要求这个)保存网络和载入网络的结构一致,且变量名称必须一致,这是caffe ...
- 『TensorFlow』第十一弹_队列&多线程&TFRecod文件_我辈当高歌
TF数据读取队列机制详解 一.TFR文件多线程队列读写操作 TFRecod文件写入操作 import tensorflow as tf def _int64_feature(value): # val ...
- 『TensorFlow』第三弹_可视化框架介绍_悄悄问圣僧
添加记录节点 -> 汇总记录节点 -> run汇总节点 -> [书写器生成]书写入文件 [-> 刷新缓冲区] 可视化关键点: 注意, 1.with tf.name_scope( ...
- 『TensorFlow』第十弹_队列&多线程_道路多坎坷
一.基本队列: 队列有两个基本操作,对应在tf中就是enqueue&dequeue tf.FIFOQueue(2,'int32') import tensorflow as tf '''FIF ...
- 『TensorFlow』专题汇总
TensorFlow:官方文档 TensorFlow:项目地址 本篇列出文章对于全零新手不太合适,可以尝试TensorFlow入门系列博客,搭配其他资料进行学习. Keras使用tf.Session训 ...
- 『TensorFlow』模型保存和载入方法汇总
『TensorFlow』第七弹_保存&载入会话_霸王回马 一.TensorFlow常规模型加载方法 保存模型 tf.train.Saver()类,.save(sess, ckpt文件目录)方法 ...
- 『PyTorch x TensorFlow』第八弹_基本nn.Module层函数
『TensorFlow』网络操作API_上 『TensorFlow』网络操作API_中 『TensorFlow』网络操作API_下 之前也说过,tf 和 t 的层本质区别就是 tf 的是层函数,调用即 ...
随机推荐
- java框架之Spring(1)-入门
介绍 概述 Spring 是一个开放源代码的设计层面框架,它解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用.Spring 是于 2003 年兴起的一个轻量级的 J ...
- 竖倾斜ScrollView
using UnityEngine; using UnityEngine.EventSystems; public class ObliqueScroll : MonoBehaviour,IDragH ...
- Java中 == 和 equals 的问题
== : 它的作用是判断两个对象的地址是不是相等.即,判断两个对象是不是同一个对象.(基本数据类型==比较的是值,引用数据类型==比较的是内存地址) equals() : 它的作用也是判断两个对象是否 ...
- 平常比较多实用的SQL
创建数据库 创建之前判断该数据库是否存在 if exists (select * from sysdatabases where name='databaseName') drop database ...
- excel 八位二进制转换为十六进制公式
=BIN2HEX(C16&D16&E16&F16&G16&H16&I16&J16,2)
- Key in_hidden/batch_normalization/beta not found in checkpoint
可能原因:不同参数的结果保存到了同一文件夹下 解决方法:不同参数结果放在不同的checkpoints tf.train.Saver().save(sess, self.checkpoint_dir + ...
- Matlab的用法总结
1. 对序列进行洗牌 randperm() randperm()产生随机的序列 %if filepaths 是一个5*1的结构体,then cshuffle = randperm(length(fil ...
- 软件工程实践小项目之模拟wc.exe的小程序
github源码和工程文件地址:https://github.com/Jackchenyu/Word_counts/tree/smart 基本要求:要实现wc的基本功能即文件中字符数.单词数.行数的统 ...
- 《CSS世界》读书笔记(八)
<!-- <CSS世界>张鑫旭著 --> 替换元素和非替换元素的距离有多远? 观点1:替换元素和非替换元素之间只隔了一个src属性! 在Firefox浏览器下,没有src属性的 ...
- ftp权限设置大全!!!
1.登录和对匿名用户的设置write_enable=YES //是否对登录用户开启写权限.属全局性设置.默认NOlocal_enable=YES ...