tf.transpose()的用法
一、tensorflow官方文档内容
transpose(
a,
perm=None,
name='transpose'
)
Defined in tensorflow/python/ops/array_ops.py.
See the guides: Math > Matrix Math Functions, Tensor Transformations > Slicing and Joining
Transposes a. Permutes the dimensions according to perm.
The returned tensor's dimension i will correspond to the input dimension perm[i]. If perm is not given, it is set to (n-1...0), where n is the rank of the input tensor. Hence by default, this operation performs a regular matrix transpose on 2-D input Tensors.
For example:
# '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]] # 'perm' is more useful for n-dimensional tensors, for n > 2
# 'x' is [[[1 2 3]
# [4 5 6]]
# [[7 8 9]
# [10 11 12]]]
# Take the transpose of the matrices in dimension-0
tf.transpose(x, perm=[0, 2, 1]) ==> [[[1 4]
[2 5]
[3 6]] [[7 10]
[8 11]
[9 12]]]
Args:
a: ATensor.perm: A permutation of the dimensions ofa.name: A name for the operation (optional).
Returns:
A transposed Tensor.
二、中文翻译
transpose(
a,
perm=None,
name='transpose'
)
Defined in tensorflow/python/ops/array_ops.py.
See the guides: Math > Matrix Math Functions, Tensor Transformations > Slicing and Joining
a的转置是根据 perm 的设定值来进行的。
返回数组的 dimension(尺寸、维度) i与输入的 perm[i]的维度相一致。如果未给定perm,默认设置为 (n-1...0),这里的 n 值是输入变量的 rank 。因此默认情况下,这个操作执行了一个正规(regular)的2维矩形的转置。
例子:
# '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]] # 'perm' is more useful for n-dimensional tensors, for n > 2
# 'x' is [[[1 2 3]
# [4 5 6]]
# [[7 8 9]
# [10 11 12]]]
# Take the transpose of the matrices in dimension-0
tf.transpose(x, perm=[0, 2, 1]) ==> [[[1 4]
[2 5]
[3 6]] [[7 10]
[8 11]
[9 12]]]
参数:
a: a 是一个张量(Tensor)perm: perm 是 a 维度的置换name:操作的名称(可选).
返回值:
返回的是一个转置的张量。
三、解释
tf.transpose(input, [dimension_1, dimenaion_2,..,dimension_n]):这个函数主要适用于交换输入张量的不同维度用的,如果输入张量是二维,就相当是转置。dimension_n是整数,如果张量是三维,就是用0,1,2来表示。这个列表里的每个数对应相应的维度。如果是[2,1,0],就把输入张量的第三维度和第一维度交换。
tf.transpose()的用法的更多相关文章
- tf.transpose函数的用法讲解
tf.transpose函数中文意思是转置,对于低维度的转置问题,很简单,不想讨论,直接转置就好(大家看下面文档,一看就懂). tf.transpose(a, perm=None, name='tra ...
- TensorFlow tf.app&tf.app.flags用法介绍
TensorFlow tf.app&tf.app.flags用法介绍 TensorFlow tf.app argparse tf.app.flags 下面介绍 tf.app.flags.FL ...
- tf.concat, tf.stack和tf.unstack的用法
tf.concat, tf.stack和tf.unstack的用法 tf.concat相当于numpy中的np.concatenate函数,用于将两个张量在某一个维度(axis)合并起来,例如: a ...
- tf.transpose函数解析
tf.transpose函数解析 觉得有用的话,欢迎一起讨论相互学习~Follow Me tf.transpose(a, perm = None, name = 'transpose') 解释 将a进 ...
- 【转载】 TensorFlow tf.app&tf.app.flags用法介绍
作 者:marsggbo 出 处:https://www.cnblogs.com/marsggbo版权声明:署名 - 非商业性使用 - 禁止演绎,协议普通文本 | 协议法律文本. ---------- ...
- python numpy的transpose函数用法
#MXNET的N*C*H*W在numpy打印时比较直观#mxnet卷积层# 输入数据格式是:batch * inchannel * height * width# 输出数据格式是:batch * ou ...
- TensorFlow tf.gradients的用法详细解析以及具体例子
tf.gradients 官方定义: tf.gradients( ys, xs, grad_ys=None, name='gradients', stop_gradients=None, ) Cons ...
- tf.cast()的用法(转)
一.函数 tf.cast() cast( x, dtype, name=None ) 将x的数据格式转化成dtype.例如,原来x的数据格式是bool, 那么将其转化成float以后,就能够将其转化成 ...
- tf.truncated_normal的用法
tf.truncated_normal(shape, mean, stddev) :shape表示生成张量的维度,mean是均值,stddev是标准差.这个函数产生正太分布,均值和标准差自己设定.这是 ...
随机推荐
- 【python原理解析】gc原理初步解析
python的gc是会用到:引用计数.标记-清除和分代收集,首先说明一下什么是引用计数 可以通过sys模块中的getrefcount()方法获取某个对象的引用计数 python本身的数据类型有基础类型 ...
- Springboot学习05-自定义错误页面完整分析
Springboot学习06-自定义错误页面完整分析 前言 接着上一篇博客,继续分析Springboot错误页面问题 正文 1-自定义浏览器错误页面(只要将自己的错误页面放在指定的路径下即可) 1-1 ...
- 信号基础知识---单频矩形脉冲信号CW
%CW%参考:声呐技术 P27,31clc;close all;clear all;%参数-------------------------f0=50;T=0.1;%时宽B=1/T;fs=1000;% ...
- python深入理解类和对象
1,鸭子类型和多态 当看到一只鸟走起来像鸭子,游泳起来像鸭子,叫起来也像鸭子,那这只鸟就是鸭子 是不是比较混乱,看个例子: # -*- coding:UTF-8 -*- __autor__ = 'zh ...
- $.fn.extend() 问:我来这个世上到底是干嘛的?
好好好 乖 本宝宝来告诉你 你来是干嘛的啊~ 话不多说 直接上码 当然如下代码是在jquery环境下运行的 HTML JS 完事~~~ 当你点击div元素的时候 你会发现弹出来“我被单击了”这句 ...
- Linux 自动挂载硬盘的方法
每次重启后,都需要手动挂载硬盘( sudo mount ),非常不方便,使用一下步骤可以实现硬盘的自动挂载 第一步 获取硬盘的基本信息(UUID TYPE) sudo blkid 第二步 修改 / ...
- JNI 记
Java Native Interface(JNI)从零开始详细教程 ================================================================ ...
- java动态生成验证码图片
package cn.lijun.checkimg; import java.awt.image.BufferedImage;import java.io.BufferedReader; import ...
- ABP框架系列之二十七:(Feature-Management-特征管理)
Introduction Most SaaS (multi-tenant) applications have editions (packages) those have different fea ...
- android 学习网站
菜鸟教程 http://www.runoob.com/android/android-tutorial.html Android基础入门教程 http://www.runoob.com/w3cnot ...