Deep learning for the physical layer

Lecture 7 · Machine Learning for ICE · University of Klagenfurt, 2023

Nunzio Alexandro Letizia

This lecture

Lecture 7 of 8

Back to communications, with the tools of lectures 2 to 6:

  1. The neural receiver: decoding as classification
  2. The autoencoder: learning the transmitter and the receiver together

From Machine Learning for ICE at the University of Klagenfurt, first taught in 2022: this is the 2023 edition, so some of it may be a little dated. All lectures.

The neural receiver

01

The receiver as one learning problem

The receiver can be treated as one supervised learning problem. Tasks usually solved one by one, such as channel estimation, equalization (demodulation), channel decoding and source decoding, can in principle be solved jointly by a neural network.

y(t) Demodulator Channel decoder Source decoder \hat s_k

traditional approach

y(t) Neural receiver \hat s_k

learning approach

Decoding is classification

Input message s\sim p_S(s) Transmitter not trainable x\sim p_X(x) Medium p_{Y\mid X}(y\mid x) y\sim p_Y(y) Receiver trainable Estimated message \hat s\sim p_S(s\mid y;\theta)

With M possible messages, the receiver is a classifier with M outputs: a network takes the received samples y_1,y_2,\dots and returns the probabilities p_S(s=s_0\mid y;\theta),\,p_S(s=s_1\mid y;\theta),\dots through a softmax.

A neural decoder: seven received samples in, two hidden layers, a softmax over sixteen messages out.

It is trained with the cross-entropy, over pairs of transmitted messages and received samples:

\hat\theta=\arg\min_\theta\,-\mathbb{E}_{(s,y)\sim p(s,y)}\big[\log p_S(s\mid y;\theta)\big]

Assignment 1: a neural decoder

s_k Source encoder b_k: 0101 Hamming (7,4) encoder c_k: 0101100 BPSK modulator x_k

The messages s_k\in\{0,1,\dots,15\} are converted to 4 bits \mathbf{b}_k, then encoded with the Hamming (7,4) code:

\mathbf{c}_k=\mathbf{b}_k\,\mathbf{G}_{7,4}\bmod2,\qquad\mathbf{G}_{7,4}=\begin{bmatrix}1&0&0&0&1&0&1\\0&1&0&0&1&1&1\\0&0&1&0&1&1&0\\0&0&0&1&0&1&1\end{bmatrix}

For example, s_k=5 gives \mathbf{b}_k=[0\,1\,0\,1] and \mathbf{c}_k=[0\,1\,0\,1\,1\,0\,0].

  1. Simulate the transmission over an AWGN channel: y_k=x_k+n_k.
  2. Design and train a neural network, with the cross-entropy, that decodes y_k into the transmitted message s_k.
  3. Evaluate the bit error rate for several noise powers, and compare it with maximum-likelihood decoding.

Assignment 1: the outcome

def build_classifier(self):
    model = Sequential()
    model.add(Dense(100, input_dim=7))
    model.add(LeakyReLU(alpha=0.2))
    model.add(GaussianNoise(0.3))     # regularizes training
    model.add(Dense(100))
    model.add(LeakyReLU(alpha=0.2))
    model.add(Dense(16, activation='softmax'))

# one network per Eb/N0: 500 steps of 256 noisy codewords
data_rx = data_tx + eps*np.random.normal(0, 1, (batch_size, 7))
y_cat = to_categorical(from_zero_mean_bits_to_digit(2*data_tx_1-1, 2), num_classes=16)
d_loss = self.combined.train_on_batch(data_rx, y_cat)

Error probability against Eb/N0 for the neural decoder and for maximum-likelihood decoding: the two curves overlap up to about 3 dB, then the neural decoder falls slightly behind.

neural decoder (ND) against maximum likelihood (MaxL)

The network learns the maximum-likelihood decoder almost exactly, without being told the code: the curves overlap up to about 3 dB and part only where errors become rare, and so are the training examples of them.

A detail of the script: it divides the bit errors by the code length once more, so the vertical axis is 7 times too low. The comparison between the two decoders is unaffected.

The autoencoder

02

Transmitter and receiver, together

Treat the whole communication chain as one learning problem.

The tasks of the transmitter (coding, modulation) and of the receiver (equalization, demodulation, decoding) have always been solved separately, which leads to sub-optimal solutions. Instead, see transmitter and receiver as two neural networks joined into one end-to-end model: the autoencoder.

s_k Transmitter x_k Medium model y_k Receiver \hat s_k

the autoencoder: trained end to end, with the channel as a layer in the middle

Learning the code

Input message s\sim p_S(s) Transmitter trainable x\sim p_X(x) Medium p_{Y\mid X}(y\mid x) y\sim p_Y(y) Receiver trainable Estimated message \hat s\sim p_S(s\mid y;\theta)

Decoding is still a classification problem. But now the encoder learns its own channel code x: the transmitter maps the message, one-hot, to the channel inputs x_1,\dots,x_n, the receiver maps the channel outputs back to the probabilities of the messages.

The autoencoder is trained end to end with the cross-entropy:

\hat\theta=\arg\min_\theta\,-\mathbb{E}_{(s,y)\sim p(s,y)}\big[\log p_S(s\mid y;\theta)\big]

where \theta now holds the parameters of both networks. The gradients flow from the receiver, through the channel, back to the transmitter: the channel model must be differentiable.

Autoencoders, more generally

The input is s\sim p_S(s) and the task is to estimate the input itself, so this can be cast as an unsupervised problem: what we really learn is an internal representation x\sim p_X(x) that is robust to channel impairments and noise.

Unlike autoencoders for compression, here the code is not meant to be small but robust: the code length n (channel uses per message) typically adds redundancy. The communication rate is

R=\frac{\log_2M}{n}\quad\text{[bits per channel use]}

with M the number of messages. Autoencoders are used for

  • compression and feature extraction
  • data reconstruction (denoising)
  • machine translation (the encoder-decoder transformer)
  • data generation (variational autoencoders, next lecture)

A regularization term is often added to the loss.

Assignment 2: an autoencoder

The autoencoder as layers: a one-hot message, two dense layers of the transmitter, power normalization, a Gaussian noise layer, and two dense layers of the receiver ending in a softmax.

Consider an autoencoder with M=16 messages and a code of length n=2.

  1. Design the transmitter E(\cdot) and the receiver D(\cdot) as neural networks.
  2. Simulate an AWGN channel, y_k=x_k+n_k, implemented as a layer of the network between them.
  3. Train the autoencoder with the cross-entropy, and estimate the transmitted messages s_k.
  4. Evaluate the bit error rate for several noise powers.
  5. Plot the learned codes x_k=E(s_k;\theta_E), and comment on them.

Assignment 2: the solution

k, n = 4, 1                  # M = 2^k = 16 messages, 1 complex channel use
R = k / (2*n)                # 2 bits per real channel use
N = pow(10, -0.1*EbN0) / (2*R)    # noise power for this Eb/N0

s_in = Input(shape=(16,))         # one-hot message
x = self.transmitter(s_in)        # Dense(16, relu), Dense(2)
# the channel, as layers: average power 1, then AWGN
x_n = BatchNormalization(axis=-1, center=False, scale=False)(x)
y = GaussianNoise(np.sqrt(N))(x_n)
s_out = self.receiver(y)          # Dense(16, relu), Dense(16, softmax)

self.combined = Model(s_in, s_out)
self.combined.compile(loss='categorical_crossentropy', optimizer=Adam(0.01, 0.5))

The 16-QAM constellation: a 4 by 4 grid of points, each with a small cloud of noisy received samples.

the yardstick, not the network’s output: 16-QAM

The batch normalization is the power constraint, and the noise layer is the channel: gradients flow through both. The interesting result is the plot of the learned codes x_k: compare its BLER with that of 16-QAM, the textbook answer for 16 points in a plane.

The original idea: T. O’Shea, J. Hoydis, An introduction to deep learning for the physical layer, 2017.

Next: Lecture 8, generative models