1. 程式人生 > >tf.sequence_mask 例項

tf.sequence_mask 例項

import tensorflow as tf
tf.enable_eager_execution()
print(tf.sequence_mask([1, 3, 2], 5))

列印結果:
tf.Tensor(
[[ True False False False False]
[ True True True False False]
[ True True False False False]], shape=(3, 5), dtype=bool)

總結:
[batch_size]的轉成[batch_size,seq_length]