Skip to content
heliaEDGE
Reference
HELIA

tcn

Temporal convolutional network (TCN) is a type of convolutional neural network (CNN) that is commonly used for sequence modeling tasks such as speech recognition, text generation, and video classification. TCN is a fully convolutional network that consists of a series of dilated causal convolutional layers. The dilated convolutional layers allow TCN to have a large receptive field while maintaining a small number of parameters. TCN is also fully parallelizable, which allows for faster training and inference times.

For more info, refer to the original paper Temporal Convolutional Networks: A Unified Approach to Action Segmentation.

Parameters are in helia_edge.models.tcn_params.

Functions

Name Description
build TCN model from TcnParams
normalization Normalization layer
tcn_block_lg TCN large block
tcn_block_mb TCN mbconv block
tcn_block_sm TCN small block
tcn_core TCN core
tcn_layer TCN functional layer

The TCN architecture has been modified to allow the following:

  • Convolutional pairs can be factorized into depthwise separable convolutions.
  • Squeeze and excitation (SE) blocks can be added between convolutional pairs.
  • Normalization can be set between batch normalization and layer normalization.
  • ReLU is replaced with the approximated ReLU6.

The following example builds a TCN from TcnParams and TcnBlockParams through a ModelSpec.

import helia_edge as helia
params = helia.models.TcnParams(
input_kernel=(1, 3),
input_norm="batch",
blocks=[
helia.models.TcnBlockParams(filters=8, kernel=(1, 3), dilation=(1, 1), dropout=0.1, ex_ratio=1, se_ratio=0, norm="batch"),
helia.models.TcnBlockParams(filters=16, kernel=(1, 3), dilation=(1, 2), dropout=0.1, ex_ratio=1, se_ratio=0, norm="batch"),
helia.models.TcnBlockParams(filters=24, kernel=(1, 3), dilation=(1, 4), dropout=0.1, ex_ratio=1, se_ratio=4, norm="batch"),
helia.models.TcnBlockParams(filters=32, kernel=(1, 3), dilation=(1, 8), dropout=0.1, ex_ratio=1, se_ratio=4, norm="batch"),
],
output_kernel=(1, 3),
include_top=True,
num_classes=5,
use_logits=True,
)
model = helia.models.build(helia.models.ModelSpec(params=params, input_shape=(1, 800, 1)))

Machine-readable model

function

Normalization layer

helia_edge/models/tcn.py:63

normalization(norm: str, name: str) -> keras.Layer

Normalization layer

Parameters of normalization
NameTypeDefaultDescription
normstrRequiredNormalization type
namestrRequiredName
Returns of normalization
TypeDescription
keras.Layerkeras.Layer: Layer
function

TCN large block

helia_edge/models/tcn.py:92

tcn_block_lg(params: TcnBlockParams, name: str) -> keras.Layer

TCN large block

Parameters of tcn_block_lg
NameTypeDefaultDescription
paramsTcnBlockParamsRequiredParameters
namestrRequiredName
Returns of tcn_block_lg
TypeDescription
keras.Layerkeras.Layer: Layer
function

TCN mbconv block

helia_edge/models/tcn.py:157

tcn_block_mb(params: TcnBlockParams, name: str) -> keras.Layer

TCN mbconv block

Parameters of tcn_block_mb
NameTypeDefaultDescription
paramsTcnBlockParamsRequiredParameters
namestrRequiredName
Returns of tcn_block_mb
TypeDescription
keras.Layerkeras.Layer: Layer
function

TCN small block

helia_edge/models/tcn.py:258

tcn_block_sm(params: TcnBlockParams, name: str) -> keras.Layer

TCN small block

Parameters of tcn_block_sm
NameTypeDefaultDescription
paramsTcnBlockParamsRequiredParameters
namestrRequiredName
Returns of tcn_block_sm
TypeDescription
keras.Layerkeras.Layer: Layer
function

tcn_core

Python

TCN core

helia_edge/models/tcn.py:344

tcn_core(params: TcnParams) -> keras.Layer

TCN core

Parameters of tcn_core
NameTypeDefaultDescription
paramsTcnParamsRequiredParameters
Returns of tcn_core
TypeDescription
keras.Layerkeras.Layer: Layer
function

tcn_layer

Python

TCN functional layer

helia_edge/models/tcn.py:373

tcn_layer(x: keras.KerasTensor, params: TcnParams) -> keras.KerasTensor

TCN functional layer

Parameters of tcn_layer
NameTypeDefaultDescription
xkeras.KerasTensorRequiredInput tensor
paramsTcnParamsRequiredParameters
Returns of tcn_layer
TypeDescription
keras.KerasTensorkeras.KerasTensor: Output tensor
function

build

Python

Build a TCN model.

helia_edge/models/tcn.py:428

build(
params: TcnParams,
input_shape: tuple[int | None, ...],
*,
batch_size: int | None = None,
name: str | None = None,
) -> keras.Model

Build a TCN model.

Parameters of build
NameTypeDefaultDescription
paramsTcnParamsRequiredModel parameters.
input_shapetuple[int | None, ...]RequiredInput shape without the batch axis; None for a variable axis.
batch_sizeint | NoneNoneStatic batch size; None for a dynamic batch.
namestr | NoneNoneModel name; the family when None.
Returns of build
TypeDescription
keras.Modelkeras.Model: The model, named ``tcn`` unless ``name`` is given.