Vik*_*ter 0 python conv-neural-network pytorch
我有以下模型,但它返回错误。不知道为什么。我尝试过谷歌搜索,但到目前为止还没有找到任何东西。我的输入是 6 x 6 的 numpy 数组。
class Net(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(1, 16, kernel_size=(3,3), stride=1, padding=0)
self.conv2 = nn.Conv2d(16, 32, kernel_size=(3,3), stride=1, padding=0)
self.conv3 = nn.Conv2d(32, 64, kernel_size=(3,3), stride=1, padding=0)
self.fc1 = nn.Linear(64*4*4, 320)
self.fc2 = nn.Linear(320, 160)
self.out = nn.Linear(160, 2)
def forward(self, x):
x = self.conv1(x)
x = F.relu(x)
x = F.max_pool2d(x, kernel_size=2, stride=2)
x = self.conv2(x)
x = F.relu(x)
x = F.max_pool2d(x, kernel_size=2, stride=2)
x = self.conv3(x)
x = F.relu(x)
x = F.max_pool2d(x, kernel_size=2, stride=2)
x = x.reshape(-1, 64*4*4)
#x = torch.flatten(x)
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.out(x)
return F.softmax(x, dim=1)
Run Code Online (Sandbox Code Playgroud)
我的输入是 6x6 numpy 数组,出现以下错误,知道为什么吗?
RuntimeError: Calculated padded input size per channel: (2 x 2). Kernel size: (3 x 3). Kernel size can't be greater than actual input size
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18390 次 |
| 最近记录: |