MCPcopy Create free account
hub / github.com/649453932/Chinese-Text-Classification-Pytorch / forward

Method forward

models/DPCNN.py:57–73  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

55 self.fc = nn.Linear(config.num_filters, config.num_classes)
56
57 def forward(self, x):
58 x = x[0]
59 x = self.embedding(x)
60 x = x.unsqueeze(1) # [batch_size, 250, seq_len, 1]
61 x = self.conv_region(x) # [batch_size, 250, seq_len-3+1, 1]
62
63 x = self.padding1(x) # [batch_size, 250, seq_len, 1]
64 x = self.relu(x)
65 x = self.conv(x) # [batch_size, 250, seq_len-3+1, 1]
66 x = self.padding1(x) # [batch_size, 250, seq_len, 1]
67 x = self.relu(x)
68 x = self.conv(x) # [batch_size, 250, seq_len-3+1, 1]
69 while x.size()[2] > 2:
70 x = self._block(x)
71 x = x.squeeze() # [batch_size, num_filters(250)]
72 x = self.fc(x)
73 return x
74
75 def _block(self, x):
76 x = self.padding2(x)

Callers

nothing calls this directly

Calls 1

_blockMethod · 0.95

Tested by

no test coverage detected