对tensorflow 中tile函数的使用详解
时间:2021-05-27 08:43:03|栏目:Python代码|点击: 次
tensorflow中tile是用来复制tensor的指定维度,具体看下面的代码:
import tensorflow as tf a = tf.constant([[1, 2], [3, 4], [5, 6]], dtype=tf.float32) a1 = tf.tile(a, [2, 2]) with tf.Session() as sess: print(sess.run(a1))
结果就是:
[[ 1. 2. 1. 2.] [ 3. 4. 3. 4.] [ 5. 6. 5. 6.] [ 1. 2. 1. 2.] [ 3. 4. 3. 4.] [ 5. 6. 5. 6.]]
因为
a1 = tf.tile(a, [2, 2]) 表示把a的第一个维度复制两次,第二个维度复制2次。
上一篇:python批量检查两个对应的txt文件的行数是否一致的实例代码
栏 目:Python代码
下一篇:Python中常用的os操作汇总
本文地址:http://www.codeinn.net/misctech/129736.html






