简体   繁体   English

python 中的 CNN 模块给出错误大小不匹配,m1:[12288 x 26],m2:[12288 x 26]

[英]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.

相关问题 Pytorch GRU 错误 RuntimeError:尺寸不匹配,m1:[1600 x 3],m2:[50 x 20] - Pytorch GRU error RuntimeError : size mismatch, m1: [1600 x 3], m2: [50 x 20] Pytorch:尺寸不匹配错误,尽管矩阵的尺寸匹配(m1:[256 x 200],m2:[256 x 200]) - Pytorch: size mismatch error although the sizes of the matrices do match (m1: [256 x 200], m2: [256 x 200]) RuntimeError:大小不匹配,m1:[28 x 28],m2:[784 x 128] - RuntimeError: size mismatch, m1: [28 x 28], m2: [784 x 128] 初学者 PyTorch:运行时错误:大小不匹配,m1:[16 x 2304000],m2:[600 x 120] - Beginner PyTorch : RuntimeError: size mismatch, m1: [16 x 2304000], m2: [600 x 120] Pytorch RuntimeError:大小不匹配,m1:[1 x 7744],m2:[400 x 120] - Pytorch RuntimeError: size mismatch, m1: [1 x 7744], m2: [400 x 120] RuntimeError:尺寸不匹配,m1:[32 x 1],m2:[32 x 9] - RuntimeError: size mismatch, m1: [32 x 1], m2: [32 x 9] RuntimeError: size mismatch, m1: [4 x 784], m2: [4 x 784] at /pytorch/aten/src/TH/generic/THTensorMath.cpp:136 - RuntimeError: size mismatch, m1: [4 x 784], m2: [4 x 784] at /pytorch/aten/src/TH/generic/THTensorMath.cpp:136 RuntimeError:大小不匹配,m1:[5 x 10],m2:[5 x 32] 在 /pytorch/aten/src/TH/generic/THTensorMath.cpp - RuntimeError: size mismatch, m1: [5 x 10], m2: [5 x 32] at /pytorch/aten/src/TH/generic/THTensorMath.cpp 如何修复此 RuntimeError:大小不匹配,m1:[64 x 103],m2:[550 x 50] - How do I fix this RuntimeError: size mismatch, m1: [64 x 103], m2: [550 x 50] 将格式为M = [((a,x),(b,y)]]的列表分成M1 = [a,b]和M2 = [x,y] - Separate lists of format M=[(a,x), (b,y)] into M1=[a,b] and M2=[x,y]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM