示例#1
0
    def test_run_symmetric(self):
        """Test random mask driver with per-neuron sparsity."""
        experiment_dir = tempfile.mkdtemp()
        self._eval_flags = dict(
            epochs=1,
            experiment_dir=experiment_dir,
            mask_type='symmetric',
        )

        with flagsaver.flagsaver(**self._eval_flags):
            random_mask.main([])

        with self.subTest(name='tf_summary_file_exists'):
            outfile = path.join(experiment_dir, '*', 'events.out.tfevents.*')
            files = glob.glob(outfile)

            self.assertTrue(len(files) == 1 and path.exists(files[0]))
示例#2
0
    def test_run_conv(self):
        """Test random mask driver with CNN model."""
        experiment_dir = tempfile.mkdtemp()
        self._eval_flags = dict(
            epochs=1,
            experiment_dir=experiment_dir,
            model='MNIST_CNN',
        )

        with flagsaver.flagsaver(**self._eval_flags):
            random_mask.main([])

        with self.subTest(name='tf_summary_file_exists'):
            outfile = path.join(experiment_dir, '*', 'events.out.tfevents.*')
            files = glob.glob(outfile)

            self.assertTrue(len(files) == 1 and path.exists(files[0]))