Swap your LSTM for dilated causal convolutions
It implements Temporal Convolutional Networks as a drop-in Keras layer, offering a convolutional alternative to LSTMs for long sequences.

What it does
keras-tcn is a single-purpose Keras layer that implements Temporal Convolutional Networks using stacks of dilated causal convolutions. You drop it into a TensorFlow model in place of recurrent layers to process sequences, with the usual 3-D input shape (batch, timesteps, features). The layer exposes familiar knobs—filters, kernel size, dilation rates, dropout, and batch or layer normalization—along with less common ones like a non-causal padding mode for offline prediction.
The interesting bit
The selling point is memory without recurrence. By exponentially increasing dilation rates, the layer expands its receptive field across the whole sequence without backpropagating through time, which sidesteps vanishing gradients and allows parallel convolutional training. The README includes explicit receptive-field math and warns that any input history exceeding that field is silently zeroed out.
Key highlights
- Claims better accuracy than LSTM/GRU on several long-sequence benchmarks (Sequential MNIST, Adding Problem, Copy Memory, Word-level PTB).
- Causal by default for real-time use, with an optional non-causal mode that looks ahead but breaks streaming.
- Configurable receptive field via dilation stacks; the README provides the exact formula and tuning notes for matching it to your sequence length.
- Supports variable-length sequences (
timestepscan beNone). - Tested across TensorFlow 2.9 through 2.19; includes a working R example linked from the issues.
Caveats
- Sequences longer than the layer’s receptive field are padded with zeros for the excess history, so you must size dilations deliberately.
- The non-causal mode is explicitly unsuitable for real-time applications.
- The working R example is only available via a GitHub issue, not first-party documentation.
Verdict
Worth a look if you are hitting LSTM memory limits on long time-series or language tasks and want a Keras-native convolutional replacement. Skip it if you need a full framework; this is just the layer.
Frequently asked
- What is philipperemy/keras-tcn?
- It implements Temporal Convolutional Networks as a drop-in Keras layer, offering a convolutional alternative to LSTMs for long sequences.
- Is keras-tcn open source?
- Yes — philipperemy/keras-tcn is open source, released under the MIT license.
- What language is keras-tcn written in?
- philipperemy/keras-tcn is primarily written in Python.
- How popular is keras-tcn?
- philipperemy/keras-tcn has 2k stars on GitHub.
- Where can I find keras-tcn?
- philipperemy/keras-tcn is on GitHub at https://github.com/philipperemy/keras-tcn.