babysor/MockingBird · error · ValueError
unknown encoder_attn_layer:
Error message
unknown encoder_attn_layer:
What it means
Raised when selfattention_layer_type in the Conformer encoder is not 'selfattn' or 'rel_selfattn'. The message text ('unknown encoder_attn_layer') is misleading; the failing variable is selfattention_layer_type.
Source
Thrown at models/ppg_extractor/encoder/conformer_encoder.py:188
if selfattention_layer_type == "selfattn":
logging.info("encoder self-attention layer type = self-attention")
encoder_selfattn_layer = MultiHeadedAttention
encoder_selfattn_layer_args = (
attention_heads,
attention_dim,
attention_dropout_rate,
)
elif selfattention_layer_type == "rel_selfattn":
assert pos_enc_layer_type == "rel_pos"
encoder_selfattn_layer = RelPositionMultiHeadedAttention
encoder_selfattn_layer_args = (
attention_heads,
attention_dim,
attention_dropout_rate,
)
else:
raise ValueError("unknown encoder_attn_layer: " + selfattention_layer_type)
convolution_layer = ConvolutionModule
convolution_layer_args = (attention_dim, cnn_module_kernel, activation)
self.encoders = repeat(
num_blocks,
lambda lnum: EncoderLayer(
attention_dim,
encoder_selfattn_layer(*encoder_selfattn_layer_args),
positionwise_layer(*positionwise_layer_args),
positionwise_layer(*positionwise_layer_args) if macaron_style else None,
convolution_layer(*convolution_layer_args) if use_cnn_module else None,
dropout_rate,
normalize_before,
concat_after,
),
)
if self.normalize_before:View on GitHub (pinned to 28dc5e14f1)
Solutions
- Set selfattention_layer_type to 'selfattn' or 'rel_selfattn'
- If 'rel_selfattn', pair it with pos_enc_layer_type='rel_pos'
- Use a conformer reference config from the repo
Example fix
# before selfattention_layer_type: context_attn # after selfattention_layer_type: rel_selfattn pos_enc_layer_type: rel_pos
Defensive patterns
Strategy: validation
Validate before calling
assert selfattention_layer_type in ('selfattn', 'rel_selfattn'), selfattention_layer_type
if selfattention_layer_type == 'rel_selfattn':
assert pos_enc_layer_type == 'rel_pos' Prevention
- Note the misleading message text — log the actual variable when wrapping
- Cross-validate pos_enc/selfattn pairs before construction
When it happens
Trigger: Constructing the conformer encoder with selfattention_layer_type other than 'selfattn'/'rel_selfattn' (e.g. 'context_attn' copied from a transformer config).
Common situations: Copying a vanilla transformer/ESPnet ASR config into a conformer training run; misspelled attention type.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- unknown pos_enc_layer:
- unknown input_layer:
- Support only linear or conv1d.
- unknown encoder_attn_layer:
- unknown pos_enc_layer:
AI-assisted analysis of babysor/MockingBird@28dc5e14f1 (2026-08-27).
Data as JSON: /api/errors/1dd718e14d622574.
Report an issue: GitHub.