Firstly I’m very sorry with this newbie question. I couldn’t find an efficient answer. I want to create a mask with zeros and ones for the n by n matrix. For value each i-th row I want to set the columns between i-a and i+a to 1 and rest of them to 0.
As an example of the values
n = 4 (4x4 matrix)
a = 1
I want to get a matrix as follows.
How can I implement this in the best way in Pytorch? Thanks in advance…