babysor/MockingBird · error · ValueError

unknown pos_enc_layer:

Error message

unknown pos_enc_layer: 

What it means

Same as the conformer variant: the vanilla transformer Encoder constructor rejects pos_enc_layer_type values outside {'abs_pos','scaled_abs_pos','rel_pos'}.

Source

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

        selfattention_layer_type="selfattn",
        activation_type="swish",
        use_cnn_module=False,
        cnn_module_kernel=31,
        padding_idx=-1,
    ):
        """Construct an Encoder object."""
        super(Encoder, self).__init__()

        activation = get_activation(activation_type)
        if pos_enc_layer_type == "abs_pos":
            pos_enc_class = PositionalEncoding
        elif pos_enc_layer_type == "scaled_abs_pos":
            pos_enc_class = ScaledPositionalEncoding
        elif pos_enc_layer_type == "rel_pos":
            assert selfattention_layer_type == "rel_selfattn"
            pos_enc_class = RelPositionalEncoding
        else:
            raise ValueError("unknown pos_enc_layer: " + pos_enc_layer_type)

        if input_layer == "linear":
            self.embed = torch.nn.Sequential(
                torch.nn.Linear(idim, attention_dim),
                torch.nn.LayerNorm(attention_dim),
                torch.nn.Dropout(dropout_rate),
                pos_enc_class(attention_dim, positional_dropout_rate),
            )
        elif input_layer == "conv2d":
            self.embed = Conv2dSubsampling(
                idim,
                attention_dim,
                dropout_rate,
                pos_enc_class(attention_dim, positional_dropout_rate),
            )
        elif input_layer == "vgg2l":
            self.embed = VGG2L(idim, attention_dim)
        elif input_layer == "embed":

View on GitHub (pinned to 28dc5e14f1)

Solutions

  1. Use 'abs_pos', 'scaled_abs_pos', or 'rel_pos'
  2. For 'rel_pos' also set selfattention_layer_type='rel_selfattn'
  3. Validate config against a working transformer example

Example fix

# before
pos_enc_layer_type: abspos

# after
pos_enc_layer_type: abs_pos
Defensive patterns

Strategy: validation

Validate before calling

assert pos_enc_layer_type in {'abs_pos','scaled_abs_pos','rel_pos'}

Prevention

When it happens

Trigger: Constructing models/ppg_extractor/encoder/encoder.py's Encoder with an invalid pos_enc_layer_type string.

Common situations: Config drift from ESPnet versions; typo; combining rel_pos without rel_selfattn triggers the assert just above.

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/652b55dc2203cf50. Report an issue: GitHub.