def test_get_sequence_lengths_from_binary_mask(self):
binary_mask = torch.ByteTensor([[1, 1, 1, 0, 0, 0],
[1, 1, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0]])
lengths = util.get_lengths_from_binary_sequence_mask(binary_mask)
numpy.testing.assert_array_equal(lengths.numpy(), numpy.array([3, 2, 6, 1]))
评论列表
文章目录