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

Fix conv padding for even kernel widths

parent 10bf4074
......@@ -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(
......
......@@ -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])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment