babysor/MockingBird · error · ValueError

unknown pos_enc_layer:

Error message

unknown pos_enc_layer: 

What it means

Raised by the Conformer encoder constructor when pos_enc_layer_type is not one of the supported values ('abs_pos', 'scaled_abs_pos', 'rel_pos').

Source

Thrown at models/ppg_extractor/encoder/conformer_encoder.py:99

        no_subsample=False,
        subsample_by_2=False,
    ):
        """Construct an Encoder object."""
        super().__init__()
        
        self._output_size = attention_dim
        idim = input_size

        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":
            logging.info("Encoder input layer type: conv2d")
            if no_subsample:
                self.embed = Conv2dNoSubsampling(
                    idim,
                    attention_dim,
                    dropout_rate,
                    pos_enc_class(attention_dim, positional_dropout_rate),
                )
            else:

View on GitHub (pinned to 28dc5e14f1)

Solutions

  1. Set pos_enc_layer_type to 'abs_pos', 'scaled_abs_pos', or 'rel_pos'
  2. If 'rel_pos', also set selfattention_layer_type='rel_selfattn' (there is an assert)
  3. Copy a known-good conformer config from the repo's examples

Example fix

# before
pos_enc_layer_type: rel-pos   # typo

# after
pos_enc_layer_type: rel_pos
selfattention_layer_type: rel_selfattn
Defensive patterns

Strategy: validation

Validate before calling

allowed = {'abs_pos', 'scaled_abs_pos', 'rel_pos'}
assert pos_enc_layer_type in allowed, pos_enc_layer_type
if pos_enc_layer_type == 'rel_pos':
    assert selfattention_layer_type == 'rel_selfattn'

Prevention

When it happens

Trigger: Constructing the conformer encoder with an invalid pos_enc_layer_type string, e.g. from a config that passes 'none' or a typo like 'rel-pos'.

Common situations: Porting ESPnet configs between versions where positional-encoding option names changed; typos in YAML config; using a newer ESPnet option name not present in this fork.

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/644943f732905729. Report an issue: GitHub.