[英]CNN module in python gives error size mismatch, m1: [12288 x 26], m2: [12288 x 26]
I'm having some issues with my CNN model and I don't understand what I'm doing wrong.我的 CNN model 有一些问题,我不明白我做错了什么。 I've tried to change my model multiple times to look like m1: 12288 x 26 and 26 x 12288, but I'm not quite sure how to do that.
我尝试多次更改我的 model 以使其看起来像 m1:12288 x 26 和 26 x 12288,但我不太确定该怎么做。 Could anyone please help me out?
有人可以帮我吗?
self.conv1 = torch.nn.Conv1d(input_size, 256, kernel_size)
self.conv2 = torch.nn.Conv1d(256, 256, kernel_size)
self.fc1 = torch.nn.Linear(256*input_size, output_size)
or或者
#self.conv1 = torch.nn.Conv1d(48, 256, 1)
#self.conv2 = torch.nn.Conv1d(256, 48, 1)
#self.fc1 = torch.nn.Linear(48*256, 26)
The model looks like: model 看起来像:
CNN(
(conv1): Conv1d(48, 256, kernel_size=(1,), stride=(1,))
(conv2): Conv1d(256, 256, kernel_size=(1,), stride=(1,))
(fc1): Linear(in_features=12288, out_features=26, bias=True)
)
The error I get "RuntimeError: size mismatch, m1: [12288 x 26], m2: [12288 x 26] at..\aten\src\TH/generic/THTensorMath.cpp:41"我得到的错误“RuntimeError: size mismatch, m1: [12288 x 26], m2: [12288 x 26] at..\aten\src\TH/generic/THTensorMath.cpp:41”
Need to "flatten" it down: self.fc1 = torch.nn.Linear(256(48-(kernel_size-1)2), output_size) did the trick.需要将其“压平”: self.fc1 = torch.nn.Linear(256(48-(kernel_size-1)2), output_size) 成功了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.