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
python pytorch


source to share


No one has answered this question yet

Check out similar questions:

5116
How can I check if a file exists without exceptions?
4268
How to combine two dictionaries in one expression?
3790
How can I safely create a subdirectory?
3474
How to list all files in a directory?
3428
How to sort a dictionary by value?
3235
How to check if a list is empty?
2849
How to make a flat list from a list of lists?
2621
How do I create a chain of function decorators?
2047
How do I concatenate two lists in Python?
0
How are pitcher sizes calculated for linear layers?



All Articles
Loading...
X
Show
Funny
Dev
Pics