Skip to content

Commit 48c71b2

Browse files
committed
feat: Add a second dense layer to the emission calculation in the sequence labelling model.
1 parent 805dce2 commit 48c71b2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

delft/sequenceLabelling/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ def __init__(self, config: ModelConfig, ntags: int = None):
779779
self.dense = nn.Linear(
780780
config.num_word_lstm_units * 2, config.num_word_lstm_units
781781
)
782+
self.dense2 = nn.Linear(config.num_word_lstm_units, ntags)
782783

783784
# CRF
784785
self.crf = CRF(ntags)
@@ -821,8 +822,9 @@ def forward(
821822
lstm_out, _ = self.bilstm(x)
822823
lstm_out = self.dropout(lstm_out)
823824

824-
# Dense
825-
emissions = torch.tanh(self.dense(lstm_out))
825+
# Dense layers
826+
x = torch.tanh(self.dense(lstm_out))
827+
emissions = self.dense2(x)
826828

827829
outputs = {"logits": emissions}
828830

0 commit comments

Comments
 (0)