예제 #1
0
 def test_should_start_experiment_with_modified_plan_fc(self):
     """ Playground should start the experiment with modified plan_conv. """
     expected_specs = get_specs_conv2_cifar10()
     expected_specs.plan_fc = ['1']
     with mock.patch('playground.ExperimentIMP') as mocked_experiment:
         playground_main([ExperimentNames.IMP, ExperimentPresetNames.CONV2_CIFAR10, '--plan_fc', '1'])
         mocked_experiment.assert_called_once_with(expected_specs)
예제 #2
0
 def test_should_start_experiment_with_modified_plot_step_parameter(self):
     """ Playground should start the experiment with modified plot_step. """
     expected_specs = get_specs_lenet_mnist()
     expected_specs.plot_step = 42
     with mock.patch('playground.ExperimentIMP') as mocked_experiment:
         playground_main([ExperimentNames.IMP, ExperimentPresetNames.LENET_MNIST, '-ps', '42'])
         mocked_experiment.assert_called_once_with(expected_specs)
예제 #3
0
 def test_should_start_experiment_with_early_stop(self):
     """ Playground should start the experiment with flag for early-stopping-checkpoints during training. """
     expected_specs = get_specs_lenet_mnist()
     expected_specs.save_early_stop = True
     with mock.patch('playground.ExperimentIMP') as mocked_experiment:
         playground_main([ExperimentNames.IMP, ExperimentPresetNames.LENET_MNIST, '-es'])
         mocked_experiment.assert_called_once_with(expected_specs)
예제 #4
0
 def test_should_start_experiment_with_modified_prune_rate_fc_parameter(self):
     """ Playground should start the experiment with modified prune_rate_fc. """
     expected_specs = get_specs_lenet_mnist()
     expected_specs.prune_rate_fc = 0.5
     with mock.patch('playground.ExperimentIMP') as mocked_experiment:
         playground_main([ExperimentNames.IMP, ExperimentPresetNames.LENET_MNIST, '-prf', '0.5'])
         mocked_experiment.assert_called_once_with(expected_specs)
예제 #5
0
 def test_should_start_experiment_with_modified_prune_rate_conv_parameter(self):
     """ Playground should start the experiment with modified prune_rate_conv. """
     expected_specs = get_specs_conv2_cifar10()
     expected_specs.prune_rate_conv = 0.5
     with mock.patch('playground.ExperimentIMP') as mocked_experiment:
         playground_main([ExperimentNames.IMP, ExperimentPresetNames.CONV2_CIFAR10, '-prc', '0.5'])
         mocked_experiment.assert_called_once_with(expected_specs)
예제 #6
0
 def test_should_start_experiment_osp(self):
     """ Playground should start the OSP-experiment with correct standard specs. """
     expected_specs = get_specs_lenet_mnist()
     expected_specs.experiment_name = ExperimentNames.OSP
     with mock.patch('playground.ExperimentOSP') as mocked_experiment:
         playground_main([ExperimentNames.OSP, ExperimentPresetNames.LENET_MNIST])
         mocked_experiment.assert_called_once_with(expected_specs)
예제 #7
0
    def test_should_start_experiment_with_detailed_logging(self):
        """ Playground should start the experiment with detailed logging. """
        expected_specs = get_specs_lenet_mnist()
        expected_specs.verbosity = VerbosityLevel.DETAILED
        with mock.patch('playground.ExperimentIMP') as mocked_experiment:
            with StringIO() as interception:
                old_stdout = sys.stdout
                sys.stdout = interception

                playground_main([ExperimentNames.IMP, ExperimentPresetNames.LENET_MNIST, '-vv'])

                sys.stdout = old_stdout
                self.assertEqual("cpu\n", interception.getvalue())
                mocked_experiment.assert_called_once_with(expected_specs)
예제 #8
0
    def test_should_print_experiment_specs_osp(self):
        """ Playground should not start the OSP-experiment and print the specs. """
        expected_specs = get_specs_lenet_mnist()
        expected_specs.experiment_name = ExperimentNames.OSP
        with mock.patch('playground.ExperimentOSP') as mocked_experiment:
            with StringIO() as interception:
                old_stdout = sys.stdout
                sys.stdout = interception

                playground_main([ExperimentNames.OSP, ExperimentPresetNames.LENET_MNIST, '-l'])

                sys.stdout = old_stdout
                self.assertEqual(f"{expected_specs}\n", interception.getvalue())
                mocked_experiment.assert_not_called()
예제 #9
0
 def test_should_start_experiment_random_retrain(self):
     """ Playground should start the random-retraining-experiment with correct arguments. """
     with mock.patch('playground.ExperimentRandomRetrain') as mocked_experiment:
         playground_main([ExperimentNames.RR, 'some/path/pre-specs.json', '0', '3'])
         mocked_experiment.assert_called_once_with('../some/path/pre-specs.json', 0, 3)