Tensorflow的逆置换操作函数tf.invert_permutation
来源:互联网 发布:四字网络流行语 编辑:程序博客网 时间:2024/06/04 19:38
tf.invert_permutation(x,name=None)
计算序列的逆置换(inverse permutation)。
本操作是计算张量的索引的逆置换。x是一维的整数张量,表示一个以0为开始的索引数组,然后根据这里元素的值来放入整数什,计算公式如下:
y[x[i]] = i for i in [0, 1, ..., len(x) -1]
从0开始,没有重复和负数值。
例如:
# 张量 `x` 是 [3, 4, 0, 2, 1]
invert_permutation(x) ==> [2, 4, 3, 0, 1]
参数:
· x: 张量,必须是下面类型之一: int32, int64。 1-D。
· name: 操作的名称,可选。
返回值:
张量,与x类型相同。1-D。
#python 3.5.3/TensorFlow 1.0.1/win 10 #2017-04-26 蔡军生 http://blog.csdn.net/caimouse ##导入要使用的库import tensorflow as tfimport numpy as np#演示API的类class DemoTF: def __init__(self): '''构造函数''' self.num1 = tf.Variable([1, 2, 0, 3], dtype = tf.int32) self.num2 = tf.Variable([1, 3, 0, 2], dtype = tf.int32) self.invert1 = tf.invert_permutation(self.num1) self.invert2 = tf.invert_permutation(self.num2) def run_graph(self): init = tf.global_variables_initializer() # 初始化变量 with tf.Session() as sess: sess.run(init) self.main(sess) #运行主函数 def main(self, sess): '''主函数''' print(sess.run(self.num1)) print(sess.run(self.invert1)) print('num2: \n', sess.run(self.num2)) print(sess.run(self.invert2)) #主程序入口if __name__ == "__main__": demo = DemoTF() demo.run_graph()
结果输出如下:
[1 2 0 3]
[2 0 1 3]
num2:
[1 3 0 2]
[2 0 3 1]
>>>
1. TensorFlow API攻略
http://edu.csdn.net/course/detail/4495
2. TensorFlow入门基本教程
http://edu.csdn.net/course/detail/4369
3. C++标准模板库从入门到精通
http://edu.csdn.net/course/detail/3324
4.跟老菜鸟学C++
http://edu.csdn.net/course/detail/2901
5. 跟老菜鸟学python
http://edu.csdn.net/course/detail/2592
6. 在VC2015里学会使用tinyxml库
http://edu.csdn.net/course/detail/2590
7. 在Windows下SVN的版本管理与实战
http://edu.csdn.net/course/detail/2579
8.Visual Studio 2015开发C++程序的基本使用
http://edu.csdn.net/course/detail/2570
9.在VC2015里使用protobuf协议
http://edu.csdn.net/course/detail/2582
10.在VC2015里学会使用MySQL数据库
http://edu.csdn.net/course/detail/2672
0 0
- Tensorflow的逆置换操作函数tf.invert_permutation
- TensorFlow的reshape操作 tf.reshape
- TensorFlow的reshape操作 tf.reshape
- tf.reduce_sum tensorflow维度上的操作
- TensorFlow的reshape操作 tf.reshape
- TensorFlow的reshape操作 tf.reshape
- tensorflow的reshape操作tf.reshape()
- tensorflow生成随机数的操作 tf.random_normal & tf.random_uniform & tf.truncated_normal & tf.random_shuffle
- tensorflow的tf.equal()函数的使用方法
- tensorflow的tf.reduce_mean()函数的使用方法
- TensorFlow函数:tf.Session()和tf.Session().as_default()的区别
- tensorflow tf.concat操作
- 【Tensorflow】tf.placeholder函数
- 【Tensorflow】tf.reshape 函数
- 【Tensorflow】tf.argmax函数
- Tensorflow tf.placeholder函数
- 【Tensorflow】tf.Graph()函数
- 【Tensorflow】tf.placeholder函数
- 如何使用搜索引擎来解决某个生活或技术问题
- 在一个千万级的数据库查寻中,如何提高查询效率?
- HADOOP HDFS BALANCER介绍及经验总结
- Data privacy、Principle and Practices精简(二)
- IntelliJ IDEA 15 服务器地址注册破解
- Tensorflow的逆置换操作函数tf.invert_permutation
- XunSearch初探 ubuntu16.04 进行安装简单使用
- JSP中<meta http-equiv="pragma" content="no-cache">中http-equiv功能介绍
- iOS开发--- WKWebView导致Controller不调用dealloc
- 利用windows的性能监视器测试存储性能
- Identity Mappings in Deep Residual Networks(译)
- Spring Bean的生命周期监听
- CentOS6.8服务器LAMP环境搭建(二) 使用cmake安装MySQL5.7.18
- 记住开数组的坑