例如,
# x is a tensor
print(x)
[1, 0]
# after repeating it
print(x)
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
有沒有tf.repeat
在TensorFlow 1.10
,所以如果有實作它的最好方式更換?
提前致謝。
uj5u.com熱心網友回復:
如果您真的只能使用 Tensorflow,請1.10
嘗試以下操作:
import tensorflow as tf
x = tf.constant([1, 0])
x = tf.reshape(tf.tile(tf.expand_dims(x, -1), [1, 25]), (50, 1))
print(x)
'''
tf.Tensor(
[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0], shape=(50, 1), dtype=int32)
'''
uj5u.com熱心網友回復:
你可以用這個
import tensorflow as tf
x = tf.constant([1, 0])
temp = tf.zeros(shape=(25, 2), dtype=tf.int32)
result = tf.reshape(tf.transpose(temp x), (-1,))
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/338392.html