babysor/MockingBird · error · ValueError

unknown encoder_attn_layer:

Error message

unknown encoder_attn_layer: 

What it means

The transformer Encoder constructor rejects selfattention_layer_type values other than 'selfattn' and 'rel_selfattn'. Message says 'encoder_attn_layer' but the checked variable is selfattention_layer_type.

Source

Thrown at models/ppg_extractor/encoder/encoder.py:177

        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

  1. Use 'selfattn' or 'rel_selfattn'
  2. Pair 'rel_selfattn' with pos_enc_layer_type='rel_pos'

Example fix

# before
selfattention_layer_type: context_attn

# after
selfattention_layer_type: selfattn
Defensive patterns

Strategy: validation

Validate before calling

assert selfattention_layer_type in ('selfattn', 'rel_selfattn')

Prevention

When it happens

Trigger: Constructing the ppg_extractor Encoder with an unsupported attention type string.

Common situations: Config copied from a different ESPnet task supporting 'context_attn' etc.; typo.

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


AI-assisted analysis of babysor/MockingBird@28dc5e14f1 (2026-08-27). Data as JSON: /api/errors/d8b7dae4bca6e2c1. Report an issue: GitHub.