一、tensorflow官方文档内容

  1. transpose(
  2. a,
  3. perm=None,
  4. name='transpose'
  5. )

Defined in tensorflow/python/ops/array_ops.py.

See the guides: Math > Matrix Math FunctionsTensor 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:  

  1. # 'x' is [[1 2 3]
  2. # [4 5 6]]
  3. tf.transpose(x) ==> [[1 4]
  4. [2 5]
  5. [3 6]]
  6.  
  7. # Equivalently
  8. tf.transpose(x, perm=[1, 0]) ==> [[1 4]
  9. [2 5]
  10. [3 6]]
  11.  
  12. # 'perm' is more useful for n-dimensional tensors, for n > 2
  13. # 'x' is [[[1 2 3]
  14. # [4 5 6]]
  15. # [[7 8 9]
  16. # [10 11 12]]]
  17. # Take the transpose of the matrices in dimension-0
  18. tf.transpose(x, perm=[0, 2, 1]) ==> [[[1 4]
  19. [2 5]
  20. [3 6]]
  21.  
  22. [[7 10]
  23. [8 11]
  24. [9 12]]]

Args:

  • a: A Tensor.
  • perm: A permutation of the dimensions of a.
  • name: A name for the operation (optional).

Returns:

A transposed Tensor.

二、中文翻译

  1. transpose(
  2. a,
  3. perm=None,
  4. name='transpose'
  5. )

Defined in tensorflow/python/ops/array_ops.py.

See the guides: Math > Matrix Math FunctionsTensor Transformations > Slicing and Joining

a的转置是根据 perm 的设定值来进行的。 

返回数组的 dimension(尺寸、维度) i与输入的 perm[i]的维度相一致。如果未给定perm,默认设置为 (n-1...0),这里的 n 值是输入变量的 rank 。因此默认情况下,这个操作执行了一个正规(regular)的2维矩形的转置。

例子:

  1. # 'x' is [[1 2 3]
  2. # [4 5 6]]
  3. tf.transpose(x) ==> [[1 4]
  4. [2 5]
  5. [3 6]]
  6.  
  7. # Equivalently(等价于)
  8. tf.transpose(x, perm=[1, 0]) ==> [[1 4]
  9. [2 5]
  10. [3 6]]
  11.  
  12. # 'perm' is more useful for n-dimensional tensors, for n > 2
  13. # 'x' is [[[1 2 3]
  14. # [4 5 6]]
  15. # [[7 8 9]
  16. # [10 11 12]]]
  17. # Take the transpose of the matrices in dimension-0
  18. tf.transpose(x, perm=[0, 2, 1]) ==> [[[1 4]
  19. [2 5]
  20. [3 6]]
  21.  
  22. [[7 10]
  23. [8 11]
  24. [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],就把输入张量的第三维度和第一维度交换。 

 
----------------------------------
参考链接:
  1、 tf.transpose函数的用法: https://i.cnblogs.com/EditPosts.aspx?opt=1
  2、 tensorflow中的不懂得知识点——转置函数 transpose : http://blog.csdn.net/u010417185/article/details/51900441
  3、tensorflow官方文档 https://www.tensorflow.org/versions/r1.3/api_docs/python/tf/transpose

tf.transpose()的用法的更多相关文章

  1. tf.transpose函数的用法讲解

    tf.transpose函数中文意思是转置,对于低维度的转置问题,很简单,不想讨论,直接转置就好(大家看下面文档,一看就懂). tf.transpose(a, perm=None, name='tra ...

  2. TensorFlow tf.app&tf.app.flags用法介绍

    TensorFlow tf.app&tf.app.flags用法介绍 TensorFlow tf.app argparse  tf.app.flags 下面介绍 tf.app.flags.FL ...

  3. tf.concat, tf.stack和tf.unstack的用法

    tf.concat, tf.stack和tf.unstack的用法 tf.concat相当于numpy中的np.concatenate函数,用于将两个张量在某一个维度(axis)合并起来,例如: a ...

  4. tf.transpose函数解析

    tf.transpose函数解析 觉得有用的话,欢迎一起讨论相互学习~Follow Me tf.transpose(a, perm = None, name = 'transpose') 解释 将a进 ...

  5. 【转载】 TensorFlow tf.app&tf.app.flags用法介绍

    作 者:marsggbo 出 处:https://www.cnblogs.com/marsggbo版权声明:署名 - 非商业性使用 - 禁止演绎,协议普通文本 | 协议法律文本. ---------- ...

  6. python numpy的transpose函数用法

    #MXNET的N*C*H*W在numpy打印时比较直观#mxnet卷积层# 输入数据格式是:batch * inchannel * height * width# 输出数据格式是:batch * ou ...

  7. TensorFlow tf.gradients的用法详细解析以及具体例子

    tf.gradients 官方定义: tf.gradients( ys, xs, grad_ys=None, name='gradients', stop_gradients=None, ) Cons ...

  8. tf.cast()的用法(转)

    一.函数 tf.cast() cast( x, dtype, name=None ) 将x的数据格式转化成dtype.例如,原来x的数据格式是bool, 那么将其转化成float以后,就能够将其转化成 ...

  9. tf.truncated_normal的用法

    tf.truncated_normal(shape, mean, stddev) :shape表示生成张量的维度,mean是均值,stddev是标准差.这个函数产生正太分布,均值和标准差自己设定.这是 ...

随机推荐

  1. python 之C3算法

    C3算法只要针对的Python2.3版本之后出现的新式类MRO(method resolution order) -------继承方法查询顺序;而经典类MRO则遵循的是深度优先遍历(树形结构) (1 ...

  2. select2清除选择(选择框内的值)

    首先清空option很简单:$("#select2_id").empty();但是这样清除了之后,选中的值仍然在文本框里显示着: 这个功能很小,只是一个函数的问题,之所以写这篇文章 ...

  3. 十字线阵---CBF,传统波束形成

    %传统波束形成,CBF (Ps:这个程序是别人的,不是我写的,但是具体是在哪里找到的已经忘了) clear all; close all; clc; %---------初始化常量---------- ...

  4. vue入门一

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 735. Asteroid Collision彗星相撞后的消失数组

    [抄题]: We are given an array asteroids of integers representing asteroids in a row. For each asteroid ...

  6. [leetcode]58. Length of Last Word最后一个词的长度

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...

  7. centos 7 添加中文输入法

    中文输入法

  8. 【Node.js】安装及使用

    Node.js是在Chrome的V8 JavaScript引擎上构建的JavaScript运行时.Node.js使用事件驱动的非阻塞I / O模型,使其轻量且高效.Node.js的软件包生态系统npm ...

  9. 【Mybatis】MyBatis对表执行CRUD操作(三)

    本例在[Mybatis]MyBatis配置文件的使用(二)基础上继续学习对表执行CRUD操作 使用MyBatis对表执行CRUD操作 1.定义sql映射xml文件(EmployeeMapper.xml ...

  10. springMVC学习 十二 拦截器

    一 拦截器概述 拦截器技术比较像java web技术中的过滤器技术,都是发送 请求时被拦截器拦截,在控制器的前后添加额外功能.但是和Spring中的Aop技术是由区别的.AOP 在特定方法前后扩充(一 ...