Skip to content

AudioEncoder.forward transposes MFCC channels away, breaking the following Conv1d(40, ...) #406

Description

@thehalleyyoung

Running examples/models/agi/model.py crashes in AudioEncoder.forward with a Conv1d channel mismatch:

RuntimeError: Given groups=1, weight of size [64, 40, 3], expected input[1, 81, 40] to have 40 channels, but got 81 channels instead

In AudioEncoder.forward the MFCC output is transposed right before the conv stack (around line 139-143):

mfcc = self.mfcc_transform(x)  # (batch_size, n_mfcc=40, time)
mfcc = mfcc.transpose(1, 2)    # (batch_size, time, n_mfcc)   <-- moves the channel dim away
out = self.conv(mfcc)          # nn.Conv1d(40, 64, ...) expects 40 channels in dim 1

nn.Conv1d(40, 64, ...) expects the channel dim (n_mfcc = 40) in position 1, but the transpose(1, 2) puts time (81 here) there instead, so the conv sees 81 "channels". The transpose contradicts the comment on the conv input. Dropping that line keeps MFCC as (batch, 40, time) and the conv runs:

mfcc = self.mfcc_transform(x)  # (batch_size, n_mfcc, time)
out = self.conv(mfcc)

Note there are additional unrelated errors further down the demo (an einsum dimension mismatch in the mixture-of-experts gating), but the AudioEncoder transpose is the first and a clear one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions