Skip to content

Commit

Permalink
More test
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Dec 10, 2024
1 parent 948a74c commit d49d1e9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stanza/tests/constituency/test_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ def test_early_dropout(self, wordvec_pretrain_file):
for name, module in dropouts:
assert module.p == 0.0, "Dropout module %s was not set to 0 with early_dropout"

with tempfile.TemporaryDirectory(dir=TEST_WORKING_DIR) as tmpdirname:
# test that when turned off, early_dropout doesn't happen
args = ['--early_dropout', '-1']
_, model = self.run_train_test(wordvec_pretrain_file, tmpdirname, num_epochs=6, extra_args=args)
model = model.model
dropouts = [(name, module) for name, module in model.named_children() if isinstance(module, nn.Dropout)]
assert len(dropouts) > 0, "Didn't find any dropouts in the model!"
if all(module.p == 0.0 for module in dropouts):
raise AssertionError("All dropouts were 0 after training even though early_dropout was set to -1")

def test_train_silver(self, wordvec_pretrain_file):
"""
Test the whole thing for a few iterations on the fake data
Expand Down

0 comments on commit d49d1e9

Please sign in to comment.