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是标准差.这个函数产生正太分布,均值和标准差自己设定.这是 ...
随机推荐
- android 个人使用总结
android 中button控件去除阴影背景 style="?android:attr/borderlessButtonStyle" android 中输入账号和密码是做判断处 ...
- linux操作命令,批量注释#方法
用户,密码 1.修改密码:passwd 2.切换用户: su root 3.增加用户:adduesr+用户 4.root更改目录的权限:chown leopard:leopard data/ -R ...
- Python基础-python数据类型之字符串(四)
字符串 字符串是python中常用的数据类型,使用('或")来创建. 创建字符串: 下标索引 字符串实际上是字符的数组,所以也支持索引. str1 = 'abcdef' 切片 定义:切片是指 ...
- MESSAGE_TYPE_X in Badi:MB_DOCUMENT_UPDATE_BEFORE
Note:385830 Instead of writing code in MB_DOCUMENT_BEFORE_UPDATE,write a check in user exit MBCF0002 ...
- stark组件开发之列表页面自定义函数扩展
对于展示页面, 可能需要显示一些. 数据库中,没有的字段. 比如, 删除按钮, 编辑按钮. 这个数据库,是没有的. 所以,可能就需要, 添加一个这个东西. 比如我在渲染的时候, 给他添加两个函数进 ...
- 《笨方法学Python》加分题6
types_of_people = 10 x = f"There are {types_of_people} types of peoples." binary = "b ...
- Mad Libs游戏1
简单的输入输出 输入代码 name1=input('请输入姓名:') name2=input('请输入一个句子:') name3=input('请输入一个地点:') name4=input('请输入一 ...
- python之内部函数
1.bool,all,any (1)当内容为空时 >>> a=[] >>> bool(a) False >>> all(a) True >& ...
- iOS:使用Github托管自己本地的项目代码方式一:(Xcode方式:开发工具Xcode配置Git,由Xcode-->Source Control-->Commit)
管理代码的地方主要有:Github(国外流行).CocoaChina.Cocoa4App.中国开源社区.CSDN.博客园.简书等等..... 现在主要介绍如何使用Github托管自己的项目代码. 尊重 ...
- windows 函数
数组清零 ::ZeroMemory(首地址,大小);