簡體   English   中英

使用 PyTorch,當我有填充時,我的 Conv1d 尺寸如何減小?

[英]With PyTorch, how is my Conv1d dimension reducing when I have padding?

我的conv module是:

        return torch.nn.Sequential(
            torch.nn.Conv1d(
                in_channels=in_channels,
                out_channels=in_channels,
                kernel_size=2,
                stride=1,
                dilation=1,
                padding=1
            ),
            torch.nn.ReLU(),
            torch.nn.Conv1d(
                in_channels=in_channels,
                out_channels=in_channels,
                kernel_size=2,
                stride=1,
                dilation=2,
                padding=1
            ),
            torch.nn.ReLU(),
            torch.nn.Conv1d(
                in_channels=in_channels,
                out_channels=in_channels,
                kernel_size=2,
                stride=1,
                dilation=4,
                padding=1
            ),
            torch.nn.ReLU()
        )

forward中,我有:

down_out = self.downscale_time_conv(inputs)

inputs.sizetorch.Size([8, 161, 24]) 我希望down_out具有相同的大小,但它具有: torch.Size([8, 161, 23])

最后一個元素 go 在哪里?

答案可以在 Pytorch 在線文檔(此處)中找到。 對於每個操作,output 形狀相對於輸入參數表示:

在此處輸入圖像描述

對於每個 conv1D:

- L1 = 25 → int((24 + 2*1 - 1*(2 - 1) - 1) / 1 + 1)
- L2 = 25 → int((25 + 2*1 - 2*(2 - 1) - 1) / 1 + 1)
- L3 = 23 → int((25 + 2*1 - 4*(2 - 1) - 1) / 1 + 1)

別忘了Lin是以前的尺碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM