1. 程式人生 > 程式設計 >對tensorflow 中tile函式的使用詳解

對tensorflow 中tile函式的使用詳解

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]) 表示把a的第一個維度複製兩次,第二個維度複製2次。

以上這篇對tensorflow 中tile函式的使用詳解就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支援我們。