I’d like to be able to create this tensor without using Numpy, but I can’t find the PyTorch equivalent to Numpy’s fft.fftfreq 1:
import numpy as np	
def get_fft_scale(h, w, decay_power=.75):
    d=.5**.5 # set center frequency scale to 1
    fy = np.fft.fftfreq(h,d=d)[:,None]
    if w % 2 == 1:
        fx = np.fft.fftfreq(w,d=d)[: w // 2 + 2]
    else:
        fx = np.fft.fftfreq(w,d=d)[: w // 2 + 1]        
    freqs = (fx*fx + fy*fy) ** decay_power
    scale = 1.0 / np.maximum(freqs, 1.0 / (max(w, h)*d))
    scale = torch.Tensor(scale).float()[None,None,...,None]
    return scale