当我使用 tf.boolean_mask 时,结果是扁平化的。
tensor7 = tf.constant( [[ 0, 1, 2, 3, -1],[ 2, 3, 4, -1, -1],[ 3, 6, 5, 4, 3]], tf.int64)
mask7 = tf.constant([[ True, True, True, True, False], [ True, True, True, False, False], [ True, True, True, True, True]], tf.bool)
result7=tf.boolean_mask(tensor7, mask7, axis=0)
with tf.Session() as sess:
print(sess.run([ result7 ]))
数组([0, 1, 2, 3, 2, 3, 4, 3, 6, 5, 4, 3])]
有没有办法使用它来保留原始的 3 数组形状?各个阵列的形状应该改变,因为它们现在更短了。我正在寻找这样的东西
[数组([[ 0, 1, 2, 3 ], [ 2, 3, 4 ], [ 3, 6, 5, 4, 3]])
白猪掌柜的
相关分类