Exercises

ex-sp-ch28-01

Easy

Create a complex-valued tensor in PyTorch and compute its magnitude, phase, real, and imaginary parts. Verify z = |z| * exp(j*angle(z)).

ex-sp-ch28-02

Easy

Implement CReLU and verify it on a grid of complex numbers. Plot input and output in the complex plane.

ex-sp-ch28-03

Easy

Convert a complex signal zC64z \in \mathbb{C}^{64} to a real tensor of shape (128,)(128,) by stacking real and imaginary parts. Convert back.

ex-sp-ch28-04

Easy

Compute the MSE loss between two complex tensors using abs().pow(2).mean(). Verify it matches computing on real/imag parts separately.

ex-sp-ch28-05

Easy

Create a complex parameter with nn.Parameter(torch.randn(..., dtype=torch.cfloat)) and compute gradients through it. Print the gradient dtype.

ex-sp-ch28-06

Medium

Implement a ComplexLinear layer using the structured weight matrix approach. Compare output with native complex multiplication.

ex-sp-ch28-07

Medium

Implement modReLU with a learnable bias parameter and train it on a simple complex regression task.

ex-sp-ch28-08

Medium

Build a complex-valued CNN with 3 ComplexConv2d layers and CReLU activations. Apply it to a complex-valued 2D signal.

ex-sp-ch28-09

Medium

Implement a differentiable AWGN channel and verify that gradients flow through it correctly (the gradient of the noise should be zero).

ex-sp-ch28-10

Medium

Compare a real-split MLP (2 channels) vs a complex-structured MLP on learning the mapping h^=f(yp)\hat{h} = f(y_p) for channel estimation. Report MSE and parameter count.

ex-sp-ch28-11

Hard

Implement a differentiable OFDM forward model including IFFT, cyclic prefix addition, channel convolution, and FFT at receiver.

ex-sp-ch28-12

Hard

Train an autoencoder end-to-end through a Rayleigh fading channel. The encoder maps bits to complex symbols and the decoder recovers bits.

ex-sp-ch28-13

Hard

Implement complex BatchNorm with 2x2 covariance whitening and compare performance to independent real/imag BatchNorm.

ex-sp-ch28-14

Challenge

Verify phase equivariance empirically: apply a complex linear layer to inputs rotated by various phases and check outputs rotate equally.

ex-sp-ch28-15

Challenge

Implement a complex-valued U-Net for OFDM channel estimation on the resource grid. Compare with real-split U-Net.