对于以下Tensor:
<tf.Tensor: shape=(2, 10, 6), dtype=int64, numpy=
array([[[ 3, 16, 43, 10, 7, 431],
[ 3, 2, 6, 5, 7, 2],
[ 3, 37, 5, 7, 2, 12],
[ 3, 2, 11, 5, 7, 2],
[ 3, 2, 6, 18, 14, 195],
[ 3, 2, 6, 5, 7, 195],
[ 3, 2, 6, 5, 7, 9],
[ 3, 2, 11, 7, 2, 12],
[ 3, 16, 52, 92, 177, 923],
[ 3, 9, 43, 10, 7, 9]],
[[ 3, 2, 22, 495, 230, 4],
[ 3, 2, 22, 5, 102, 122],
[ 3, 2, 22, 5, 102, 230],
[ 3, 2, 22, 5, 70, 908],
[ 3, 2, 22, 5, 70, 450],
[ 3, 2, 22, 5, 70, 122],
[ 3, 2, 22, 5, 70, 122],
[ 3, 2, 22, 5, 70, 230],
[ 3, 2, 22, 70, 34, 470],
[ 3, 2, 22, 855, 450, 4]]], dtype=int64)>)
我想删除Tensor中的最后一个列表[ 3, 2, 22, 855, 450, 4]
。我尝试了tf.unstack
,但没有成功。
3条答案
按热度按时间yzckvree1#
您还可以简单地使用
tf.ragged.boolean_mask
来排除不需要的行:ttp71kqs2#
您可以尝试以下操作从Tensor中删除最后一个列表:
qzlgjiam3#
试试这个