How to compute loss between tensors of different dimensions?

I’m training a segmentation model whose output (predicted_output) is of dimension (256, 512, 2). I have added an attention layer in the encoder whose output (attention_mask) is of dimension (8, 16, 1). My goal is to compute a loss between this attention_mask and the predicted_output, what would be the best approach to resize either one to match the other to do so?

Hi @varungupta

Could you please share minimal reproducible code to replicate and to understand the issue better? Thank you.