Commit 0a836276 authored by Myle Ott's avatar Myle Ott
Browse files

Fix conv padding for even kernel widths

parent 10bf4074
Loading
Loading
Loading
Loading
+1 −1
Changes for fairseq/models/fconv.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class FConvEncoder(FairseqEncoder):
        self.projections = nn.ModuleList()
        self.convolutions = nn.ModuleList()
        for (out_channels, kernel_size) in convolutions:
            pad = (kernel_size - 1) // 2
            pad = (kernel_size - 1) / 2
            self.projections.append(Linear(in_channels, out_channels)
                                    if in_channels != out_channels else None)
            self.convolutions.append(
+1 −1
Changes for fairseq/modules/conv_tbc.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ class ConvTBCFunction(Function):
        kernel_size = weight_size[0]

        output = input.new(
            input_size[0] - kernel_size + 1 + pad * 2,
            input_size[0] - kernel_size + 1 + int(pad * 2),
            input_size[1],
            weight_size[2])