Ejemplo n.º 1
0
    def test_get_params(self):
        svm_repurposer = SvmRepurposer(self.source_model,
                                       self.source_model_layers)

        params = svm_repurposer.get_params()
        expected_params = {
            'context_function': 'cpu',
            'num_devices': 1,
            'feature_layer_names': ['fc1', 'fc2'],
            'c': 1.0,
            'kernel': 'linear',
            'gamma': 'auto',
            'enable_probability_estimates': False
        }

        assert params == expected_params
Ejemplo n.º 2
0
 def test_repurpose(self, mock_model_handler):
     """ Test Repurpose wrapper in meta model base class using svm repurposer object"""
     mock_model_handler.return_value = RepurposerTestUtils.get_mock_model_handler_object(
     )
     mock_model_handler.return_value.get_layer_output.return_value = self.train_feature_dict, self.train_labels
     repurposer = SvmRepurposer(self.source_model, self.source_model_layers)
     self._run_common_repurposer_tests(repurposer)
Ejemplo n.º 3
0
 def test_repurpose(self, mock_model_handler):
     """ Test Repurpose wrapper in meta model base class using svm repurposer object"""
     mock_model_handler.return_value = RepurposerTestUtils.get_mock_model_handler_object(
     )
     N = 10
     train_feature_dict_subset = {
         k: v[:N]
         for k, v in self.train_feature_dict.items()
     }
     mock_model_handler.return_value.get_layer_output.return_value = train_feature_dict_subset, self.train_labels[:
                                                                                                                  N]
     repurposer = SvmRepurposer(self.source_model, self.source_model_layers)
     self._run_common_repurposer_tests(repurposer)
Ejemplo n.º 4
0
 def test_train_model_from_features(self):
     svm_repurposer = SvmRepurposer(self.source_model,
                                    self.source_model_layers)
     model = svm_repurposer._train_model_from_features(
         self.train_features[:10], self.train_labels[:10])
     self._validate_trained_model(model)