tf.transpose()的用法

一、tensorflow官方文档内容

transpose(
    a,
    perm=None,
    name='transpose'
)

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:  

# '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: A Tensor.
  • perm: A permutation of the dimensions of a.
  • 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 FunctionsTensor 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],就把输入张量的第三维度和第一维度交换。 

 
----------------------------------
参考链接:
  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

deep_learning_Function_tensorflow_transpose()的更多相关文章

随机推荐

  1. mysql|full join 多表联查,系统报错,无法解答!

    查询语句: select 分数 from cfull join don c.姓名=d.姓名 报错: [Err] 1054 - Unknown column 'c.姓名' in 'on clause' ...

  2. 阶段3 3.SpringMVC·_07.SSM整合案例_05.ssm整合之Spring整合SpringMVC的框架

    点击超连接,执行controller里面的方法 那么就需要在Controller里面定义Service对象,就需要依赖注入进来. 启动tomcat服务器,web.xml里面的前端控制器会帮我加载spr ...

  3. C# List方法中存储的问题

    遇到一个bug,抓耳挠塞好久都没有解决,有必要记录一下. 现在我使用了一个多维list. IList<IList<int>> list = new List<IList& ...

  4. 【HANA系列】【第六篇】SAP HANA XS使用JavaScript(JS)调用存储过程(Procedures)

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列][第六篇]SAP HANA XS ...

  5. Linux目录权限管理

    Linux目录权限管理   实验目标: 通过本实验掌握centos7/rhel7目录权限的管理.包括配置目录的所属组.SGID.读/写/执行权限等. 实验步骤: 1.创建目录/home/instruc ...

  6. 应用安全 - 工具 | 平台 - gitlist - 漏洞 - 汇总

    简介 用途 Github仓库查看器 CVE-2014-4511 Date 类型 远程代码执行 影响范围 gitlist 0.4.0及之前版本

  7. Spring Boot(2)中的yaml配置简介

    搞Spring Boot的小伙伴都知道,Spring Boot中的配置文件有两种格式,properties或者yaml,一般情况下,两者可以随意使用,选择自己顺手的就行了,那么这两者完全一样吗?肯定不 ...

  8. ssh远程连接的故障排查详解

    排查故障: 1.两个机器之间是否通畅,看物理网络(网线网卡,IP是不是正确) ping ip -t 来检测物理网络是否通畅 通 不通 不通: 1.客户端到服务器端物理链路有问题 网卡 ,IP ,  网 ...

  9. Maven引入oracle驱动包

    1.下载驱动包 2.加载到本地maven库中 mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=1 ...

  10. 谷歌官方颜色库 MaterialDesignColor

    谷歌官方颜色库 MaterialDesignColor