MCPcopy Create free account
hub / github.com/modAL-python/modAL / TestDropout

Class TestDropout

tests/core_tests.py:744–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742
743
744class TestDropout(unittest.TestCase):
745 def setUp(self):
746 self.skorch_classifier = NeuralNetClassifier(Torch_Model,
747 criterion=torch.nn.CrossEntropyLoss,
748 optimizer=torch.optim.Adam,
749 train_split=None,
750 verbose=1)
751
752 def test_mc_dropout_bald(self):
753 learner = modAL.models.learners.DeepActiveLearner(
754 estimator=self.skorch_classifier,
755 query_strategy=modAL.dropout.mc_dropout_bald,
756 )
757 for random_tie_break in [True, False]:
758 for num_cycles, sample_per_forward_pass in product(range(1, 5), range(1, 5)):
759 for n_samples, n_classes in product(range(1, 5), range(1, 5)):
760 for n_instances in range(1, n_samples):
761 X_pool = torch.randn(n_samples, n_classes)
762 modAL.dropout.mc_dropout_bald(learner, X_pool, n_instances, random_tie_break, [],
763 num_cycles, sample_per_forward_pass)
764
765 def test_mc_dropout_mean_st(self):
766 learner = modAL.models.learners.DeepActiveLearner(
767 estimator=self.skorch_classifier,
768 query_strategy=modAL.dropout.mc_dropout_mean_st,
769 )
770 for random_tie_break in [True, False]:
771 for num_cycles, sample_per_forward_pass in product(range(1, 5), range(1, 5)):
772 for n_samples, n_classes in product(range(1, 5), range(1, 5)):
773 for n_instances in range(1, n_samples):
774 X_pool = torch.randn(n_samples, n_classes)
775 modAL.dropout.mc_dropout_mean_st(learner, X_pool, n_instances, random_tie_break, [],
776 num_cycles, sample_per_forward_pass)
777
778 def test_mc_dropout_max_entropy(self):
779 learner = modAL.models.learners.DeepActiveLearner(
780 estimator=self.skorch_classifier,
781 query_strategy=modAL.dropout.mc_dropout_max_entropy,
782 )
783 for random_tie_break in [True, False]:
784 for num_cycles, sample_per_forward_pass in product(range(1, 5), range(1, 5)):
785 for n_samples, n_classes in product(range(1, 5), range(1, 5)):
786 for n_instances in range(1, n_samples):
787 X_pool = torch.randn(n_samples, n_classes)
788 modAL.dropout.mc_dropout_max_entropy(learner, X_pool, n_instances, random_tie_break, [],
789 num_cycles, sample_per_forward_pass)
790
791 def test_mc_dropout_max_variationRatios(self):
792 learner = modAL.models.learners.DeepActiveLearner(
793 estimator=self.skorch_classifier,
794 query_strategy=modAL.dropout.mc_dropout_max_variationRatios,
795 )
796 for random_tie_break in [True, False]:
797 for num_cycles, sample_per_forward_pass in product(range(1, 5), range(1, 5)):
798 for n_samples, n_classes in product(range(1, 5), range(1, 5)):
799 for n_instances in range(1, n_samples):
800 X_pool = torch.randn(n_samples, n_classes)
801 modAL.dropout.mc_dropout_max_variationRatios(learner, X_pool, n_instances, random_tie_break, [],

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…