のクロスインデックススライスIは、以下の形の2つのテンソルた:Tensorflow:テンソル
tensor1 => shape(10, 99, 106)
tensor2 => shape(10, 99)
tensor2
私はtensor1
の最後の次元をスライスしtensor3
を取得するために使用する0 - 105
の範囲の値を含んでい
tensor4 = tf.gather(tensor1, tensor2)
# this causes tensor4 to be of shape (10, 99, 99, 106)
:形状
tensor3 => shape(10, 99, 99)
の私が使って試してみましたまた
、私はこのためにnumpyののcross_indexingに似ている何かを探しています何
tensor4 = tf.gather_nd(tensor1, tensor2)
# gives the error: last dimension of tensor2 (which is 99) must be
# less than the rank of the tensor1 (which is 3).
を使用。
'tensor3'の形はどうですか?単純に(10,99)ではいけませんか? – Sunreef
はい。 'tensor2'の99次元ベクトルを使って' tensor1'の3次元( '106')から' 99'値のみを選択したいと思います。 –