autokeras/engine/tuner.py
Killed 26 out of 54 mutantsSurvived
Survived mutation testing. These mutants show holes in your test suite.Mutant 23
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -36,7 +36,7 @@
preprocessors=None,
**kwargs):
super().__init__(oracle, hypermodel, **kwargs)
- self.preprocessors = nest.flatten(preprocessors)
+ self.preprocessors = None
self._finished = False
# Save or load the HyperModel.
self.hypermodel.hypermodel.save(os.path.join(self.project_dir, 'graph'))
Mutant 25
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -37,7 +37,7 @@
**kwargs):
super().__init__(oracle, hypermodel, **kwargs)
self.preprocessors = nest.flatten(preprocessors)
- self._finished = False
+ self._finished = None
# Save or load the HyperModel.
self.hypermodel.hypermodel.save(os.path.join(self.project_dir, 'graph'))
Mutant 26
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -39,7 +39,7 @@
self.preprocessors = nest.flatten(preprocessors)
self._finished = False
# Save or load the HyperModel.
- self.hypermodel.hypermodel.save(os.path.join(self.project_dir, 'graph'))
+ self.hypermodel.hypermodel.save(os.path.join(self.project_dir, 'XXgraphXX'))
# Override the function to prevent building the model during initialization.
def _populate_initial_space(self):
Mutant 33
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -64,7 +64,7 @@
x = dataset.map(lambda x, y: x)
def get_output_layer(tensor):
- tensor = nest.flatten(tensor)[0]
+ tensor = None
for layer in model.layers:
if isinstance(layer, tf.keras.layers.InputLayer):
continue
Mutant 34
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -67,7 +67,7 @@
tensor = nest.flatten(tensor)[0]
for layer in model.layers:
if isinstance(layer, tf.keras.layers.InputLayer):
- continue
+ break
input_node = nest.flatten(layer.input)[0]
if input_node is tensor:
return layer
Mutant 36
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -68,7 +68,7 @@
for layer in model.layers:
if isinstance(layer, tf.keras.layers.InputLayer):
continue
- input_node = nest.flatten(layer.input)[0]
+ input_node = None
if input_node is tensor:
return layer
return None
Mutant 37
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -69,7 +69,7 @@
if isinstance(layer, tf.keras.layers.InputLayer):
continue
input_node = nest.flatten(layer.input)[0]
- if input_node is tensor:
+ if input_node is not tensor:
return layer
return None
Mutant 40
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -75,7 +75,7 @@
for index, input_node in enumerate(nest.flatten(model.input)):
temp_x = x.map(lambda *args: nest.flatten(args)[index])
- layer = get_output_layer(input_node)
+ layer = None
while isinstance(layer, preprocessing.PreprocessingLayer):
layer.adapt(temp_x)
layer = get_output_layer(layer.output)
Mutant 41
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -78,7 +78,7 @@
layer = get_output_layer(input_node)
while isinstance(layer, preprocessing.PreprocessingLayer):
layer.adapt(temp_x)
- layer = get_output_layer(layer.output)
+ layer = None
return model
def search(self,
Mutant 42
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -84,7 +84,7 @@
def search(self,
epochs=None,
callbacks=None,
- fit_on_val_data=False,
+ fit_on_val_data=True,
**fit_kwargs):
"""Search for the best HyperParameters.
Mutant 45
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -104,7 +104,7 @@
callbacks = []
# Insert early-stopping for adaptive number of epochs.
- epochs_provided = True
+ epochs_provided = False
if epochs is None:
epochs_provided = False
epochs = 1000
Mutant 46
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -104,7 +104,7 @@
callbacks = []
# Insert early-stopping for adaptive number of epochs.
- epochs_provided = True
+ epochs_provided = None
if epochs is None:
epochs_provided = False
epochs = 1000
Mutant 48
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -112,7 +112,7 @@
callbacks.append(tf_callbacks.EarlyStopping(patience=10))
# Insert early-stopping for acceleration.
- early_stopping_inserted = False
+ early_stopping_inserted = True
new_callbacks = self._deepcopy_callbacks(callbacks)
if not utils.contain_instance(callbacks, tf_callbacks.EarlyStopping):
early_stopping_inserted = True
Mutant 49
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -112,7 +112,7 @@
callbacks.append(tf_callbacks.EarlyStopping(patience=10))
# Insert early-stopping for acceleration.
- early_stopping_inserted = False
+ early_stopping_inserted = None
new_callbacks = self._deepcopy_callbacks(callbacks)
if not utils.contain_instance(callbacks, tf_callbacks.EarlyStopping):
early_stopping_inserted = True
Mutant 51
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -114,7 +114,7 @@
# Insert early-stopping for acceleration.
early_stopping_inserted = False
new_callbacks = self._deepcopy_callbacks(callbacks)
- if not utils.contain_instance(callbacks, tf_callbacks.EarlyStopping):
+ if utils.contain_instance(callbacks, tf_callbacks.EarlyStopping):
early_stopping_inserted = True
new_callbacks.append(tf_callbacks.EarlyStopping(patience=10))
Mutant 52
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -115,7 +115,7 @@
early_stopping_inserted = False
new_callbacks = self._deepcopy_callbacks(callbacks)
if not utils.contain_instance(callbacks, tf_callbacks.EarlyStopping):
- early_stopping_inserted = True
+ early_stopping_inserted = False
new_callbacks.append(tf_callbacks.EarlyStopping(patience=10))
# Populate initial search space.
Mutant 53
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -115,7 +115,7 @@
early_stopping_inserted = False
new_callbacks = self._deepcopy_callbacks(callbacks)
if not utils.contain_instance(callbacks, tf_callbacks.EarlyStopping):
- early_stopping_inserted = True
+ early_stopping_inserted = None
new_callbacks.append(tf_callbacks.EarlyStopping(patience=10))
# Populate initial search space.
Mutant 54
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -116,7 +116,7 @@
new_callbacks = self._deepcopy_callbacks(callbacks)
if not utils.contain_instance(callbacks, tf_callbacks.EarlyStopping):
early_stopping_inserted = True
- new_callbacks.append(tf_callbacks.EarlyStopping(patience=10))
+ new_callbacks.append(tf_callbacks.EarlyStopping(patience=11))
# Populate initial search space.
hp = self.oracle.get_space()
Mutant 56
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -127,7 +127,7 @@
# Train the best model use validation data.
# Train the best model with enought number of epochs.
- if fit_on_val_data or early_stopping_inserted:
+ if fit_on_val_data and early_stopping_inserted:
copied_fit_kwargs = copy.copy(fit_kwargs)
# Remove early-stopping since no validation data.
Mutant 59
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -132,7 +132,7 @@
# Remove early-stopping since no validation data.
# Remove early-stopping since it is inserted.
- copied_fit_kwargs['callbacks'] = self._remove_early_stopping(callbacks)
+ copied_fit_kwargs['callbacks'] = None
# Decide the number of epochs.
copied_fit_kwargs['epochs'] = epochs
Mutant 62
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -136,7 +136,7 @@
# Decide the number of epochs.
copied_fit_kwargs['epochs'] = epochs
- if not epochs_provided:
+ if epochs_provided:
copied_fit_kwargs['epochs'] = self._get_best_trial_epochs()
# Concatenate training and validation data.
Mutant 64
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -150,7 +150,7 @@
model = self.get_best_models()[0]
model.save_weights(self.best_model_path)
- self._finished = True
+ self._finished = False
@staticmethod
def _remove_early_stopping(callbacks):
Mutant 65
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -150,7 +150,7 @@
model = self.get_best_models()[0]
model.save_weights(self.best_model_path)
- self._finished = True
+ self._finished = None
@staticmethod
def _remove_early_stopping(callbacks):
Mutant 67
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -154,7 +154,7 @@
@staticmethod
def _remove_early_stopping(callbacks):
- return [copy.deepcopy(callbacks)
+ return [copy.copy(callbacks)
for callback in callbacks
if not isinstance(callback, tf_callbacks.EarlyStopping)]
Mutant 68
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -163,7 +163,7 @@
return len(best_trial.metrics.metrics['val_loss']._observations)
def final_fit(self, x=None, **fit_kwargs):
- best_trial = self.oracle.get_best_trials(1)[0]
+ best_trial = self.oracle.get_best_trials(2)[0]
best_hp = best_trial.hyperparameters
model = self.hypermodel.build(best_hp)
self.adapt(model, x)
Mutant 74
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -172,7 +172,7 @@
@property
def best_model_path(self):
- return os.path.join(self.project_dir, 'best_model')
+ return os.path.join(self.project_dir, 'XXbest_modelXX')
@property
def objective(self):
Mutant 75
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -174,7 +174,6 @@
def best_model_path(self):
return os.path.join(self.project_dir, 'best_model')
- @property
def objective(self):
return self.tuner.objective
Mutant 76
--- autokeras/engine/tuner.py
+++ autokeras/engine/tuner.py
@@ -178,7 +178,6 @@
def objective(self):
return self.tuner.objective
- @property
def max_trials(self):
return self.oracle.max_trials