2017-01-21 3 views

Antwort

1

Wenn Sie req_data = y[:,x]
ersten Gebrauch machen wollen tf.transpose, so die Form des Tensor sein (8, 140)
dann tf.gather verwenden, um die Daten
weil tf.gather nur auf Achse = 0 arbeiten, um zu wählen, so transponiert zuerst dann transponieren

a = tf.constant([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 
       [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) 
a_trans = tf.transpose(a) 
b = tf.constant([2,4,5,7]) 
c = tf.gather(a_trans, b) 
c_trans = tf.transpose(c) 

with tf.Session() as sess: 
    print sess.run(c_trans) 
    #output [[3 5 6 8] 
    #  [13 15 16 18]] 
Verwandte Themen