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 __init__(self, callbacks=list([]), early_stopping_patience=12, batch_size=64, num_epochs=100, validation_fraction=0.1, shuffle=True, learning_rate=0.0001, optimizer=None, verbose=0): self.batch_size = batch_size Validation.check_is_positive_integer_greaterequals_1( num_epochs, var_name="num_epochs") self.num_epochs = num_epochs Validation.check_is_fraction(validation_fraction, var_name="validation_fraction") self.validation_fraction = validation_fraction self.shuffle = shuffle self.learning_rate = learning_rate self.optimizer = optimizer self.verbose = verbose self.callbacks = callbacks self.early_stopping_patience = early_stopping_patience
def test_check_is_positive_integer_greaterequals_1(self): with self.assertRaises(ValueError): Validation.check_is_positive_integer_greaterequals_1(-1) with self.assertRaises(ValueError): Validation.check_is_positive_integer_greaterequals_1(1.1) with self.assertRaises(ValueError): Validation.check_is_positive_integer_greaterequals_1(-1.1) with self.assertRaises(ValueError): Validation.check_is_positive_integer_greaterequals_1(0) Validation.check_is_positive_integer_greaterequals_1(1) Validation.check_is_positive_integer_greaterequals_1(2)