How to solve two levels of CNN measurement
Now I am learning CNN for nlp, a few times ago, I am trying to modify Yoon Kim's code, github link ( https://github.com/Joyce94/cnn-text-classification-pytorch ), I am trying to add convolution layer to model.py.
However I am facing a measurement problem, in other words, with the output of the first convolution layer being created as the input of the second convolution layer, it tells me that the dimension is not matched.
Can anyone help me solve this?
# one layer
self.conv13 = nn.Conv2d(Ci, 100, (3, D))
self.conv14 = nn.Conv2d(Ci, 100, (4, D))
self.conv15 = nn.Conv2d(Ci, 100, (5, D))
# two layer
self.conv23 = nn.Conv2d(100, Co, (D, Co))
self.conv24 = nn.Conv2d(100, Co, (D, Co))
self.conv25 = nn.Conv2d(100, Co, (D, Co))
x1 = self.conv(x, self.conv13) #(N,Co)
print("convvv", x1)
# two layer
if self.args.cuda:
self.conv23 = [model.cuda() for model in self.conv23]
self.conv24 = [model.cuda() for model in self.conv24]
self.conv25 = [model.cuda() for model in self.conv25]
x1 = x1.unsqueeze(1)
x4 = self.conv(x1, self.conv23) #(N,Co)
x = self.pool(x4)
+3
bamtercelboo
source
to share
No one has answered this question yet
Check out similar questions:
5116
4268
3790
3474
3428
3235
2849
2621
2047
0