deep_learning_Function_tensorflow_transpose()
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]]# Equivalentlytf.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-0tf.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-0tf.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],就把输入张量的第三维度和第一维度交换。
deep_learning_Function_tensorflow_transpose()的更多相关文章
随机推荐
- JndiObjectFactoryBean 配置数据源
转: JndiObjectFactoryBean 配置数据源 2017年08月29日 22:04:28 病毒先生 阅读数:7338 版权声明:本文为博主原创文章,未经博主允许不得转载. https ...
- jdk 1.8中的list排序
首先看看collections实现 public static <T> void sort(List<T> list, Comparator<? super T> ...
- 跨平台python异步回调机制实现和使用方法
跨平台python异步回调机制实现和使用方法 这篇文章主要介绍了python异步回调机制的实现方法,提供了使用方法代码 1 将下面代码拷贝到一个文件,命名为asyncore.py 代码如下: impo ...
- MySQL使用order by field()自定义排序
MySQL的自定义排序和Oracle相比,要简单得多. 假设在表v_education的列schoolRecord中,有以下字段:'小学','初中','高中','专科','本科','硕士','博士'. ...
- MongoDB数据节点基础操作
1.查看集群中各节点的状态: rs0:PRIMARY> rs.status() 2.查看集群中各节点配置情况: rs0:PRIMARY> rs.conf() 3.主节点降级为从节点: rs ...
- 掌握Pod-Pod调度策略
一 Pod生命周期管理 1.1 Pod生命周期 Pod在整个生命周期过程中被系统定义了如下各种状态. 状态值 描述 Pending API Server已经创建该Pod,且Pod内还有一个或多个容器的 ...
- 不容错过的 Babel7 知识
对 Babel 的配置项的作用不那么了解,是否会影响日常开发呢?老实说,大多情况下没有特别大的影响(毕竟有搜索引擎). 不过呢,还是想更进一步了解下,于是最近认真阅读了 Babel 的文档,外加不断编 ...
- Android开发 所需组件配置
1 Unity中的Android Build Support下载 在Unity中的File>Building Settings>Android>Open Download Page, ...
- @Conditional注解
根据条件动态创建bean public class TestConditon implements Condition { public boolean matches(ConditionContex ...
- 编译安装MySQL数据库
1. 安cmake工具 # yum install -y cmake 2. 创建mysql用户 # useradd -M -s /sbin/nologin mysql 3. 创建数据目录 # mkdi ...