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. flutter shared_preferences 异步变同步

    前言 在开发原生iOS或Native应用时,一般有判断上一次安装的版本和当前版本是否是同一个版本,如果不是同一个版本,则要显示引导页,这个过程是把版本号持久化存储起来,在每一次启动时进行判断,这个过程 ...

  2. phpstrom--------config php interpreter

    phpstrom是一款比较好用的php代码编辑器,使用phpstrom进行代码编辑时我可能会需要看一下在网页上的实际效果,但是PHPstrom本身只是一款编辑器,不具备运行功能,我们需要自己安装一个服 ...

  3. 绝对好用Flash多文件大文件上传控件

    本实例采用的是Uploadify上传插件,.NET程序,源程序是从网上找的,但是有Bug,已经修改好,并标有部分注释.绝对好用,支持单文件.多文件上传,支持大文件上传,已经过多方面测试,保证好用. 以 ...

  4. weak_ptr用法

    http://note.youdao.com/noteshare?id=39c10fda83320b2851e2073a5f69321c

  5. python配置主机名

    .准备hosts模板 mkdir -p /k8s/profile cat >/k8s/profile/hosts<<EOF 192.168.0.91 test1 192.168.0. ...

  6. 【TypeScript】学习笔记 把一些需要记的记录一下

    安装typescript: npm install -g typescript 启动typesctipt自动编译: tsc 文件名.ts --watch 函数参数默认值: 1.有默认值参数的,声明在最 ...

  7. GO-REDIS的一些高级用法

    1. 前言 说到Golang的Redis库,用到最多的恐怕是redigo 和 go-redis.其中 redigo 不支持对集群的访问.本文想聊聊go-redis 2个高级用法 2. 开启对Clust ...

  8. 在Ubuntu上安装Hive

    1.下载hive2.3.5 解压缩并改名为hive目录,放到/usr/local下(注意权限) sudo mv apache-hive-2.3.5-bin /usr/local/hive 2.修改目录 ...

  9. Hadoop单机模式/伪分布式模式/完全分布式模式

    一.Hadoop的三种运行模式(启动模式) 一.单机(非分布式)模式 这种模式在一台单机上运行,没有分布式文件系统,而是直接读写本地操作系统的文件系统. 默认情况下,Hadoop即处于该模式,用于开发 ...

  10. CSS3面包屑菜单导航

    在线演示 本地下载