Thanks a lot for your reply!
I like the first method, I will try to make some code that works using the torch.no_grad() method (even if is my first time to use it  )
For the sake of completeness, regarding the second method you posted I’m a bit reluctant to think that I can add a small epsilon to the norm. For example, assuming that I’m trying to minimize the following loss
loss = torch.norm(filtered_out)**2

then the filter will probably converge to [0,0,0,0].