espnet2.asr_transducer.encoder.building.build_body_blocks
espnet2.asr_transducer.encoder.building.build_body_blocks
espnet2.asr_transducer.encoder.building.build_body_blocks(configuration: List[Dict[str, Any]], main_params: Dict[str, Any], output_size: int) → MultiBlocks
Build encoder body blocks.
This function constructs a series of encoder body blocks based on the given configuration and main parameters. It allows for the creation of different types of blocks, including Branchformer, Conformer, Conv1d, and E-Branchformer, according to the specified configuration.
- Parameters:
- configuration – A list of dictionaries containing the configuration for each body block. Each dictionary may specify the type of block, the number of blocks, and various hyperparameters.
- main_params – A dictionary containing the main parameters for the encoder, including activation functions, normalization types, and other relevant settings.
- output_size – The output size of the architecture after processing through the body blocks.
- Returns: A function encapsulating all encoder blocks, which can be : invoked to create the full encoder body.
- Return type:MultiBlocks
- Raises:NotImplementedError – If an unsupported block type is specified in the configuration.
Examples
configuration = [ : {“block_type”: “branchformer”, “num_blocks”: 2, “hidden_size”: 256, : “linear_size”: 128, “dropout_rate”: 0.1}, <br/> {“block_type”: “conformer”, “num_blocks”: 1, “hidden_size”: 256, : “linear_size”: 128, “pos_wise_dropout_rate”: 0.1},
] main_params = {
“pos_wise_act”: “relu”, “norm_type”: “layer_norm”, “after_norm_class”: “layer_norm”, “after_norm_args”: {“eps”: 1e-6}, “blockdrop_rate”: 0.0,
} output_size = 512
body_blocks = build_body_blocks(configuration, main_params, output_size)