RuntimeError: "slow_conv2d_cpu" not implemented for 'ComplexDouble'

vin: <p>While training a CNN network, this error raised <code>RuntimeError: "slow_conv2d_cpu" not implemented for 'ComplexDouble'</code>. My datatype are  <code>dtype=torch.complex128</code>. So now, which <code>dtype</code> do I need for my network to train? Is there any issue? Or to convert my data tensor in <code>dtype = torch.float16</code>?</p>
<pre><code class="lang-auto">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)
</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/e/1ee8117767e6aabbf425921463e02bc05435f2d7.png" data-download-href="https://discuss.pytorch.org/uploads/default/1ee8117767e6aabbf425921463e02bc05435f2d7" title="333"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/e/1ee8117767e6aabbf425921463e02bc05435f2d7_2_690x302.png" alt="333" data-base62-sha1="4ppwJD2rPeiFNXf7hwwHAOOTn7x" width="690" height="302" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/e/1ee8117767e6aabbf425921463e02bc05435f2d7_2_690x302.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/e/1ee8117767e6aabbf425921463e02bc05435f2d7_2_1035x453.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/1/e/1ee8117767e6aabbf425921463e02bc05435f2d7_2_1380x604.png 2x" data-dominant-color="2F3034"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">333</span><span class="informations">1592×698 103 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

JuanFMontesinos: <p>I think convolutions for complex numbers are not supported currently.<br>
The easiest approach is to convert them to a 2_channel tensor via<br>
(with spectrograms)</p>
<pre><code class="lang-auto">tensor = torch.view_as_real(tensor)
tensor = tensor.permute(0,3,1,2) # B x [Re,Im] x F x T
</code></pre>
<p>or just<br>
<code>tensor = torch.view_as_real(tensor) # * x [Re,Im]</code> for a generic tensor of any shape</p>

vin: <p>Solved. <code>tensor = torch.view_as_real(tensor)</code> is a perfect solution. Thank you Sir</p>

KFrank: <p>Hi Juan (and Vin)!</p>
<aside class="quote no-group" data-username="JuanFMontesinos" data-post="2" data-topic="151806" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/juanfmontesinos/48/76115_2.png" class="avatar"> JuanFMontesinos:</div>
<blockquote>
<p>I think convolutions for complex numbers are not supported currently.</p>
</blockquote>
</aside>
<p>As an aside, <code>Conv2d</code> has complex support in the latest nightly (version<br>
1.12) (but does not yet in version 1.11).</p>
<p>Best.</p>
<p>K. Frank</p>