I have a similar problem but in regression CNN I extract the output from 4D tensor to calculate the loss with 1D target but the problem now that both have a different sizes or different length
0,outputs torch.Size([2484]), targets torch.Size([3690])
1,outputs torch.Size([3270]), targets torch.Size([3884])

how can I solve this problem, I have different sizes between outputs(from CNN) and the targets , should I feel the size difference with zeros or that will effect the loss calculation?!