# How to implement or avoid masking for transformer?

When it comes to using Transformers for image captioning is there any reason to use masking?

I currently have a resnet101 encoder and am trying to use the features as the input for a transformer model in order to generate a caption for the image, is there any need to use masking? and what would I mask if I did need to?

Any help would be much appreciated

If you're using a library such as Trax which contains great submodules for various Transformers (Skipping, BERT, Vanilla and Reformer) you can use the inbuilt trax.data.inputs.add_loss_weights() function and provide a value for the id_to_mask parameter.

Example Usage:

train_generator = trax.data.inputs.add_loss_weights(