def __init__(self, explained_model, model_builder, masking_operation, loss, downsample_factors=(1, ), num_models=1): super(CXPlain, self).__init__() self.explained_model = explained_model self.model_builder = model_builder self.masking_operation = masking_operation self.loss = loss self.last_masked_data = None self.prediction_model = None Validation.check_is_positive_integer_greaterequals_1( num_models, var_name="num_models") self.num_models = num_models Validation.check_downsample_factors_at_initialisation( downsample_factors) self.downsample_factors = downsample_factors
def test_check_downsample_factors_at_initialisation(self): with self.assertRaises(ValueError): Validation.check_downsample_factors_at_initialisation((-1,)) with self.assertRaises(ValueError): Validation.check_downsample_factors_at_initialisation(-1) with self.assertRaises(ValueError): Validation.check_downsample_factors_at_initialisation(1.1) with self.assertRaises(ValueError): Validation.check_downsample_factors_at_initialisation(-1.1) with self.assertRaises(ValueError): Validation.check_downsample_factors_at_initialisation((3.3, 2.2)) Validation.check_downsample_factors_at_initialisation((3, 2, 1))