babysor/MockingBird · error · ValueError

Number of encoders needs to be more than one. {}

Error message

Number of encoders needs to be more than one. {}

What it means

encoder_for in models/ppg_extractor/encoders.py builds a list of encoders from args.etype/elayers/eunits arrays; it requires num_encs (= len(args.etype)) > 1 for the multi-encoder branch and rejects num_encs <= 1 here.

Source

Thrown at models/ppg_extractor/encoders.py:298

                                        List of dimensions of inputs, e.g. [83,83]
    :param List or List of List subsample: subsample factors, e.g. [1,2,2,1,1], or
                                        List of subsample factors of each encoder. e.g. [[1,2,2,1,1], [1,2,2,1,1]]
    :rtype torch.nn.Module
    :return: The encoder module
    """
    num_encs = getattr(args, "num_encs", 1)  # use getattr to keep compatibility
    if num_encs == 1:
        # compatible with single encoder asr mode
        return Encoder(args.etype, idim, args.elayers, args.eunits, args.eprojs, subsample, args.dropout_rate)
    elif num_encs >= 1:
        enc_list = torch.nn.ModuleList()
        for idx in range(num_encs):
            enc = Encoder(args.etype[idx], idim[idx], args.elayers[idx], args.eunits[idx], args.eprojs, subsample[idx],
                          args.dropout_rate[idx])
            enc_list.append(enc)
        return enc_list
    else:
        raise ValueError("Number of encoders needs to be more than one. {}".format(num_encs))

View on GitHub (pinned to 28dc5e14f1)

Solutions

  1. Ensure args.etype/elayers/eunits/edropout_rate are lists with at least 2 entries
  2. If you truly have one encoder, call the single-Encoder constructor directly instead of encoder_for
  3. Check how the YAML/argparse parses etype — wrap the value in a list

Example fix

# before
etype: vggblstmp   # scalar → num_encs=1

# after
etype: [vggblstmp, vggblstmp]
elayers: [3, 3]
Defensive patterns

Strategy: validation

Validate before calling

num_encs = len(args.etype) if isinstance(args.etype, (list, tuple)) else 1
assert num_encs > 1, 'encoder_for requires >=2 encoders; pass etype as a list'

Prevention

When it happens

Trigger: Calling encoder_for with args.etype containing a single element (num_encs == 1), or num_encs == 0, while the multi-encoder path expects at least two.

Common situations: Using a single-encoder config in code that always routes through the multi-encoder branch; YAML lists not parsed as lists (etype given as a scalar string becomes len==1).

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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