title: FFT loss in PyTorch
body: <p>I want to compute the loss between the GT and the output of my network (called TDN) in the frequency domain by computing 2D FFT. The tensors are of dim <code>batch x channel x height x width</code></p>
  <pre><code>amp_ip, phase_ip = 2DFFT(TDN(ip))
  amp_gt, phase_gt = 2DFFT(TDN(gt))
  loss = ||amp_ip - amp_gt||
  </code></pre>
  <p>For computing FFT I can use <a href="https://pytorch.org/docs/1.4.0/torch.html#torch.fft" rel="nofollow noreferrer">torch.fft(ip, signal_ndim = 2)</a>. But the output is in <code>a + j b</code> format i.e rectangular coordinates and NOT decomposed into phase and amplitude. How can I convert <code>a + j b</code> into <code>amp exp(j phase)</code> format in PyTorch? A side concern is also if <code>signal_ndims</code> be kept 2 to compute 2D FFT or something else?</p>
  <p>The following description, which describes the loss that I plan to implement, maybe useful.</p>
  <p><a href="https://i.stack.imgur.com/ttomw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ttomw.png" alt="enter image description here" /></a></p>