假设我有以下两个向量,一个用于开始索引,另一个用于结束索引
start_index = [1, 1, 2]
end_index = [3, 4, 3]
在下面我有最终布尔矩阵的形状
shape = [3, 6]
我想生成以下布尔矩阵
bool_mat = [[False, True, True, True, False, False]
[False, True, True, True, True, False]
[False, False, True, True, False, False]]
对于每一行,True 从 start_index 中的索引开始,以 end_index 中的索引结束,其他地方为 False,
bool_mat[i, start_index[i]:end_index[i]+1] = True
如何在 TensorFlow 中做到这一点?谢谢!
相关分类