I am looking for a way to find a 2D pattern in a MxNxR tensor/array with pytorch or numpy. For instance, to see if a dictionary of tensor of boolean pattern (e.g. {6x6 : freq}) exist in a larger boolean tensor (e.g. 3x256x256).
Then I want to update my patterns and frequencies of the dictionary.
I was hoping that there was a pytorchi way of doing it, instead of having loops over it, or have an optimized loop for doing it.
As far as I know, torch.where works when we have a scalar value. I’m not sure how should I do, if I have a tensor of 6x6 instead of a value. I looked into Finding Patterns in a Numpy Array , but I don't think that it's feasible to follow it for a 2D pattern.