RuntimeError: "slow_conv2d_cpu" not implemented for 'ComplexDouble'

While training a CNN network, this error raised RuntimeError: "slow_conv2d_cpu" not implemented for 'ComplexDouble'. My datatype are dtype=torch.complex128. So now, which dtype do I need for my network to train? Is there any issue? Or to convert my data tensor in dtype = torch.float16?

trainloader = create_data_loader(data_save, batch_size)
    ntotal_len = len(trainloader)
    for epoch in range(epochs):
        model.train()
        running_loss = 0.0

        for target, labels in trainloader:
            target, labels = target.to(DEVICE), labels.to(DEVICE)

            outputs = model(target)
            loss = criterion(outputs, labels)

I think convolutions for complex numbers are not supported currently.
The easiest approach is to convert them to a 2_channel tensor via
(with spectrograms)

tensor = torch.view_as_real(tensor)
tensor = tensor.permute(0,3,1,2) # B x [Re,Im] x F x T

or just
tensor = torch.view_as_real(tensor) # * x [Re,Im] for a generic tensor of any shape

1 Like

Solved. tensor = torch.view_as_real(tensor) is a perfect solution. Thank you Sir

Hi Juan (and Vin)!

As an aside, Conv2d has complex support in the latest nightly (version
1.12) (but does not yet in version 1.11).

Best.

K. Frank