我想通过掩码矩阵将 INF 值设置为矩阵,就像 pytorch 代码一样:
scores.data.masked_fill_(y_mask.data, -float('inf'))
我尝试使用tf.map_fn它来实现,但性能太慢。那么tensorflow有没有高效的函数来实现呢?
tf.map_fn
tensorflow pytorch
pytorch ×1
tensorflow ×1