pranavashok:

[[1, 1, 1, 0, 0, 0, 0] [0, 1, 1, 1, 0, 0, 0] [0, 0, 1, 0, 1, 0, 0] [0, 0, 0, 1, 0, 1, 0] [0, 0, 0, 0, 1, 1, 1]]


You can use this matrix as a torch.Tensor and perform a channel wise multiplication. This would force MaxPool to pick the values at instance location which have a 1 in the mask.