我有两个张量,一个是形状为[batch_size, timestep, feature]
的3d张量,另一个是形状为[batch_size, timestep]
的2d张量
例如
data = tf.constant([[[0, 0], [1, 1], [2, 2]], [[3, 3], [4, 4], [5, 5]]], dtype=tf.float32) # shape=(2, 3, 2)
mask = tf.constant([[True, True, False], [False, True, True]]) # shape=(2, 3)
我想根据数据调整遮罩
#Desired output (mask timestep with value -1)
[[[0, 0], [1, 1], [-1, -1]], [[-1, -1], [4, 4], [5, 5]]]
有没有tensorflow内置函数的解决方案或其他解决方法来做到这一点?你知道吗
我做了一个简单的解决方法(改变面具的形状),也许有更好的方法,但我现在想不出来。你知道吗
我更喜欢使用
tf.tile()
操作来展开掩码:相关问题 更多 >
编程相关推荐