Search code examples
pytorchcustomizationcomplex-numbersloss-functionautograd

_th_addr_out not supported on CPUType for ComplexFloat


I am trying to use a customized loss function for my NN. I've implemented all operations in torch and I have complex numbers among my data.

I get the error while training a NN:

RuntimeError: _th_addr_out not supported on CPUType for ComplexFloat 

Do you know any possible solution to deal with it?


Solution

  • Well it seems Complex Autograd in PyTorch is currently in a prototype state, and the backward functionality for some of function is not included.

    For example: torch.sign, which is used in the backward computation of torch.abs, is not defined for complex tensors. same for torch.mv. So I debugged my code line by line to find the functions which are not included, and replaced them with a customized function :)

    Hope for a lot more functions to be included in the next release of PyTorch.