class CNNText(nn.Module):
def __init__(self):
super(CNNText, self).__init__()
self.encoder_tit = nn.Embedding(3281, 64)
self.encoder_con = nn.Embedding(496037, 512)
self.kernel_size = 0
self.content_conv_5 = nn.Sequential(
nn.Conv1d(in_channels = 512,
out_channels = 1,
kernel_size = 5),
nn.ReLU(),
nn.MaxPool1d(kernel_size = self.kernel_size)
)
self.fc = nn.Linear(256, 9)
def forward(self, title, content):
pass
If I want to change the value of self.kernel_size in function forward.And when I change the value of kernel_size.The module is also changed.The kernel_size of maxpool1d is also changed.
How can I implement it?I can’t imagine a way to finish it.Please help me, thank you very much