← Back to software

Software story

Learning how channels depend on one another

WGLAE recovers missing or corrupted channels by learning how a dataset's variables depend on one another. During training it hides channels deliberately and in order, teaching the network to reconstruct each one from the rest. The idea is representation learning; the motivating case is EEG, where electrodes drop out mid-recording. This is the story, and the paper's code now runs on current TensorFlow in one command.

Software
WGLAE (Python, TensorFlow)
Repository
github.com/Hebaelfiqi/wglae
Datasets
7-channel synthetic EEG (CC BY-NC 4.0)
Paper
IEEE T. Cybernetics, 2022 · doi:10.1109/TCYB.2021.3049583

The problem

Sensors fail at the worst possible time

Many measurements worth taking are taken many channels at once. An EEG headset records dozens of electrodes; an aircraft, a factory line, or a robot fuses readings from banks of sensors. And in every one of these settings the same small disaster is routine: mid-recording, a channel dies. An electrode loses contact, a wire is knocked, a sensor drifts out of range.

The standard responses are painful. Throw the whole recording away, and hours of experiment time go with it. Interpolate the missing channel from its neighbours with a fixed formula, and you get a guess that ignores everything the data could have told you about how that specific channel actually behaves.

The idea

A curriculum of hidden channels

An autoencoder is a neural network that learns to reproduce its own input: it squeezes the data through a narrow middle and expands it back, so it has to discover the structure that ties the inputs together. WGLAE is not simply that autoencoder with one extra layer. It wraps the autoencoder in a small system that teaches it deliberately: a controller sits above the network like a conductor and runs training one session at a time, deciding which block of channels to hide, which samples to show, and how strongly to weight the mistakes. The figure below is that architecture.

ARCHITECTURE OF WGLAEThe network controller is the conductor. It directs three things: which data to use, which channels to hide, and how to weight the error.Network controllerγ · data controlΩ · weight controlΘ · gate controlDataOriginal InputTarget OutputGate controllerθ · gate on/offError weightgeneratorωclassic autoencoderinput gate(hides a block of channels)predictionoriginalerrorcalculationω=weightederrorerror backpropagationIn plain terms: γ picks the samples · θ picks which channels to hide · ω sets how much each channel countsTHE CURRICULUM: the hidden block advances in order, session by sessionsession 1session 2session 3and so on,every blockeach session hides a different block and trains the model to rebuild it from the surrounding channels

How to read it: the network controller at the top is the conductor. It tells the data which samples to serve (γ), the gate controller which block of channels to hide (Θ, then θ at the input gate), and the error weight generator how much each channel should count (Ω, then ω). The gated autoencoder makes its best guess, the weighted error scores it while paying extra attention to the hidden channels, and that error is sent back to teach the network. Underneath, the hidden block moves along one session at a time.

Two ideas make it work. The first is the gate layer itself, which the authors introduced in an earlier paper, the Gate Layer Autoencoder (GLAE): switching input gates on and off so a single autoencoder can be taught many inter-variable relationships at once. That earlier work concentrated on the gating mechanism. This paper builds it out. It sets out the full scheme shown in the figure above, where a network controller and its control parameters turn the gating into a structured curriculum, hiding the block in a set order so the network learns, region by region, to rebuild every part from the rest. It then adds the idea WGLAE is named for: a weight layer that judges how critical each channel is and scales the error to match, so the network works hardest on the channels that carry the dependencies rather than the easy ones. Because those choices are exposed as control parameters, one architecture can stand in for a family of models. Together, the ordered gating and the weighted error let WGLAE reconstruct incomplete data more accurately than GLAE and than ordinary autoencoders.

What we found

Graceful degradation instead of collapse

At test time, the difference shows up exactly where it should. When a channel drops out, the gated model redraws it from the surviving channels, not as a smoothed average, but as a signal that tracks the true one. And as more channels are removed, its reconstruction error stays nearly flat where a standard autoencoder's error climbs steeply: with ten channels missing at once, the standard model has effectively given up while the gated one is still working.

FILLING IN A LOST CHANNEL recorded channels channel 3 drops out mid-recording gated autoencoder reconstructed redrawn from the other channels alone reconstruction vs true signal trained by hiding each block in turn, the model learns cross-channel structure ERROR VS CHANNELS LOST standard AE gated AE 1 10 missing

Left: a channel dies mid-recording. Right: the gated autoencoder redraws it from the other channels alone; the inset shows error staying nearly flat as up to ten channels are removed.

What's in the box

The paper's code, running today

The original code is published as a Code Ocean capsule that runs on the library versions of its time: TensorFlow 2.2 and Keras 2.4, with CUDA 10.1, inside a container. This repository provides the same experiments running on current versions, so you can install with pip and run them directly. It comes in two forms: a faithful port on TensorFlow 2.15 / Keras 2 (the original scripts, changed only where a library interface moved), and a rewrite for the latest TensorFlow 2.21 / Keras 3 (the gate models re-expressed in the TensorFlow 2 style). Both reproduce the paper's baseline experiment on the synthetic dataset, and were validated against the original results.

$ pip install -r requirements-keras3.txt
$ python WGLAE_Generalized.py

The original capsule (Code Ocean, original versions) and the modernised code (GitHub, current versions) are both linked below. The gate models recover missing channels best, exactly as reported in the paper.

Who should care

Anywhere data arrives on many channels

We developed this with EEG in mind, since brain-computer interfaces are notorious for electrodes dropping out mid-session, but the mechanism is domain-agnostic. Wearables, industrial monitoring, autonomous platforms: any system that fuses multiple sensors inherits the same failure mode, and the same fix applies. The gate layer also has a second life as an analysis tool: because the model learns which channels can stand in for which, it exposes the dependency structure of the data itself. Now that it runs without the old container, it is something a new researcher can pick up, run, and build on.

Cite & explore

The formal version

H. El-Fiqi, M. Wang, K. Kasmarik, A. Bezerianos, K. C. Tan and H. A. Abbass, “Weighted Gate Layer Autoencoders,” IEEE Transactions on Cybernetics, vol. 52, no. 8, pp. 7242–7253, 2022. doi:10.1109/TCYB.2021.3049583

Get the modern code on GitHub →
Run the original on Code Ocean →
The research story in the paper gallery →

How this page was written. The research, the results, and the ideas here are mine and my co-authors’. To retell them in plain language and to refresh the code so others can run it, I worked with an AI coding and writing assistant that helped draft the text, reuse the diagrams in this site’s style, and port the software. I reviewed and edited everything, and the technical responsibility rests with me. If the prose reads a little differently from my papers, that is why.