Skip to content
heliaEDGE
Reference
HELIA

conformer

Conformer model implementation in Keras.

Parameters are in helia_edge.models.conformer_params.

Functions

Name Description
build Conformer model from ConformerParams
subsampler Subsampler block
fc_block Fully connected block
conv_block Convolutional block
att_block Attention block
conformer_block Conformer block
conformer_layer Conformer functional layer

Machine-readable model

function

Subsampler block

helia_edge/models/conformer.py:26

subsampler(
blocks: SubsampleBlockParams,
kernel_initializer: str = 'glorot_uniform',
bias_initializer: str = 'zeros',
kernel_regularizer=None,
bias_regularizer=None,
name: str | None = None,
) -> keras.Layer

Subsampler block

Parameters of subsampler
NameTypeDefaultDescription
blocksSubsampleBlockParamsRequiredSubsample block parameters
kernel_initializerstr'glorot_uniform'Kernel initializer. Defaults to "glorot_uniform".
bias_initializerstr'zeros'Bias initializer. Defaults to "zeros".
kernel_regularizer[type]NoneKernel regularizer. Defaults to None.
bias_regularizer[type]NoneBias regularizer. Defaults to None.
namestrNoneName. Defaults to None.
Returns of subsampler
TypeDescription
keras.Layerkeras.Layer: Subsampler layer
function

fc_block

Python

Fully connected block

helia_edge/models/conformer.py:85

fc_block(
depth: int,
ex_factor: int = 4,
residual_factor: float = 0.5,
dropout: float = 0,
use_bias: bool = True,
kernel_initializer: str = 'glorot_uniform',
bias_initializer: str = 'zeros',
kernel_regularizer=None,
bias_regularizer=None,
name: str = 'fc_block',
) -> keras.Layer

Fully connected block

Parameters of fc_block
NameTypeDefaultDescription
depthintRequiredDepth
ex_factorint4Expansion factor. Defaults to 4.
residual_factorfloat0.5Residual factor. Defaults to 0.5.
dropoutfloat0Dropout rate. Defaults to 0.
use_biasboolTrueUse bias. Defaults to True.
kernel_initializerstr'glorot_uniform'Kernel initializer. Defaults to "glorot_uniform".
bias_initializerstr'zeros'Bias initializer. Defaults to "zeros".
kernel_regularizer[type]NoneKernel regularizer. Defaults to None.
bias_regularizer[type]NoneBias regularizer. Defaults to None.
namestr'fc_block'Name. Defaults to "fc_block".
Returns of fc_block
TypeDescription
keras.Layerkeras.Layer: Functional layer
function

Convolutional block

helia_edge/models/conformer.py:151

conv_block(
depth: int,
kernel_size: int = 9,
dropout: float = 0.0,
padding: str = 'same',
scale_factor: int = 2,
kernel_initializer: str = 'glorot_uniform',
bias_initializer: str = 'zeros',
kernel_regularizer=None,
bias_regularizer=None,
name: str = 'conv_module',
) -> keras.Layer

Convolutional block

Parameters of conv_block
NameTypeDefaultDescription
depthintRequiredDepth
kernel_sizeint9Kernel size. Defaults to 9.
dropoutfloat0.0Dropout rate. Defaults to 0.0.
paddingstr'same'Padding. Defaults to "same".
scale_factorint2Scale factor. Defaults to 2.
kernel_initializerstr'glorot_uniform'Kernel initializer. Defaults to "glorot_uniform".
bias_initializerstr'zeros'Bias initializer. Defaults to "zeros".
kernel_regularizer[type]NoneKernel regularizer. Defaults to None.
bias_regularizer[type]NoneBias regularizer. Defaults to None.
namestr'conv_module'Name. Defaults to "conv_module".
Returns of conv_block
TypeDescription
keras.Layerkeras.Layer: Functional layer
function

att_block

Python

Attention block

helia_edge/models/conformer.py:235

att_block(
depth: int,
embedding: str = 'rel',
num_heads: int = 4,
dropout: float = 0.1,
name: str = 'att_block',
) -> keras.Layer

Attention block

Parameters of att_block
NameTypeDefaultDescription
depthintRequiredDepth
embeddingstr'rel'Embedding type. Defaults to "rel".
num_headsint4Number of heads. Defaults to 4.
dropoutfloat0.1Dropout rate. Defaults to 0.1.
namestr'att_block'Name. Defaults to "att_block".
Returns of att_block
TypeDescription
keras.Layerkeras.Layer: Functional layer
function

Conformer block

helia_edge/models/conformer.py:278

conformer_block(
depth: int,
fc_ex_factor: int = 4,
fc_res_factor: int = 0.5,
embedding: str = 'relative',
num_heads: int = 4,
kernel_size: int = 9,
dropout: float = 0.1,
use_bias: bool = True,
name: str = 'cf_block',
) -> keras.Layer

Conformer block

Parameters of conformer_block
NameTypeDefaultDescription
depthintRequiredDepth
fc_ex_factorint4FC expansion factor. Defaults to 4.
fc_res_factorint0.5FC residual factor. Defaults to 0.5.
embeddingstr'relative'Embedding type. Defaults to "relative".
num_headsint4Number of heads. Defaults to 4.
kernel_sizeint9Kernel size. Defaults to 9.
dropoutfloat0.1Dropout rate. Defaults to 0.1.
use_biasboolTrueUse bias. Defaults to True.
namestr'cf_block'Name. Defaults to "cf_block".
Returns of conformer_block
TypeDescription
keras.Layerkeras.Layer: Functional layer
function

Conformer functional layer

helia_edge/models/conformer.py:350

conformer_layer(x: keras.KerasTensor, params: ConformerParams) -> keras.KerasTensor

Conformer functional layer

Parameters of conformer_layer
NameTypeDefaultDescription
xkeras.KerasTensorRequiredInput tensor
paramsConformerParamsRequiredModel parameters.
Returns of conformer_layer
TypeDescription
keras.KerasTensorkeras.KerasTensor: Output tensor
function

build

Python

Build a Conformer model.

helia_edge/models/conformer.py:389

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

Build a Conformer model.

Parameters of build
NameTypeDefaultDescription
paramsConformerParamsRequiredModel 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 ``conformer`` unless ``name`` is given.