Tim*_*man 14 python arrays sorting tensorflow
假设我在TensorFlow中有一个数组:
[ 0.12300211, 0.51767069, 0.13886075, 0.55363625],
[ 0.47279349, 0.50432992, 0.48080254, 0.51576483],
[ 0.84347934, 0.44505221, 0.88839239, 0.48857492],
[ 0.93650454, 0.43652734, 0.96464157, 0.47236174], ..
Run Code Online (Sandbox Code Playgroud)
我想在第三列对这个数组进行排序.我该怎么做呢?我能够使用单独对每列进行排序tf.nn.top_k(),这为我提供了排序值和相应的索引.我可以使用第三列的索引对其他列重新排序,但我找不到重新排序的Op.
假设我想保持图形内容(没有Python恶作剧):
kev*_*man 12
以下作品:
a = tf.constant(...) # the array
reordered = tf.gather(a, tf.nn.top_k(a[:, 2], k=4).indices)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7990 次 |
| 最近记录: |