Repository: keras-team/autokeras

Issue:
Clean up the verbosity of AutoKeras
We can use the following feature of Keras Tuner to do it.
https://github.com/keras-team/keras-tuner/pull/312


Discussion:
I can work on it if I can get some guidance. 

Resolving patch:
diff --git a/autokeras/auto_model.py b/autokeras/auto_model.py
--- a/autokeras/auto_model.py
+++ b/autokeras/auto_model.py
@@ -207,6 +207,7 @@ def fit(
         callbacks=None,
         validation_split=0.2,
         validation_data=None,
+        verbose=1,
         **kwargs
     ):
         """Search for the best model and hyperparameters for the AutoModel.
@@ -243,6 +244,12 @@ def fit(
                 validation data should be the same as the training data.
                 The best model found would be fit on the training dataset without the
                 validation data.
+            verbose: 0, 1, or 2. Verbosity mode. 0 = silent, 1 = progress bar,
+                2 = one line per epoch. Note that the progress bar is not
+                particularly useful when logged to a file, so verbose=2 is
+                recommended when not running interactively (eg, in a production
+                environment). Controls the verbosity of both KerasTuner search and
+                [keras.Model.fit](https://www.tensorflow.org/api_docs/python/tf/keras/Model#fit)
             **kwargs: Any arguments supported by
                 [keras.Model.fit](https://www.tensorflow.org/api_docs/python/tf/keras/Model#fit).
         """
@@ -274,6 +281,7 @@ def fit(
             callbacks=callbacks,
             validation_data=validation_data,
             validation_split=validation_split,
+            verbose=verbose,
             **kwargs
         )
 
@@ -403,11 +411,16 @@ def _has_y(self, dataset):
         # It matches the single IO case.
         return len(shapes) == 2 and len(self.inputs) == 1 and len(self.outputs) == 1
 
-    def predict(self, x, batch_size=32, **kwargs):
+    def predict(self, x, batch_size=32, verbose=1, **kwargs):
         """Predict the output for a given testing data.
 
         # Arguments
             x: Any allowed types according to the input node. Testing data.
+            batch_size: Number of samples per batch.
+                If unspecified, batch_size will default to 32.
+            verbose: Verbosity mode. 0 = silent, 1 = progress bar.
+                Controls the verbosity of
+                [keras.Model.predict](https://tensorflow.org/api_docs/python/tf/keras/Model#predict)
             **kwargs: Any arguments supported by keras.Model.predict.
 
         # Returns
@@ -424,17 +437,22 @@ def predict(self, x, batch_size=32, **kwargs):
         dataset = tf.data.Dataset.zip((dataset, dataset))
         y = model.predict(dataset, **kwargs)
         y = utils.predict_with_adaptive_batch_size(
-            model=model, batch_size=batch_size, x=dataset, **kwargs
+            model=model, batch_size=batch_size, x=dataset, verbose=verbose, **kwargs
         )
         return pipeline.postprocess(y)
 
-    def evaluate(self, x, y=None, batch_size=32, **kwargs):
+    def evaluate(self, x, y=None, batch_size=32, verbose=1, **kwargs):
         """Evaluate the best model for the given data.
 
         # Arguments
             x: Any allowed types according to the input node. Testing data.
             y: Any allowed types according to the head. Testing targets.
                 Defaults to None.
+            batch_size: Number of samples per batch.
+                If unspecified, batch_size will default to 32.
+            verbose: Verbosity mode. 0 = silent, 1 = progress bar.
+                Controls the verbosity of
+                [keras.Model.evaluate](http://tensorflow.org/api_docs/python/tf/keras/Model#evaluate)
             **kwargs: Any arguments supported by keras.Model.evaluate.
 
         # Returns
@@ -455,7 +473,7 @@ def evaluate(self, x, y=None, batch_size=32, **kwargs):
         dataset = pipeline.transform(dataset)
         model = self.tuner.get_best_model()
         return utils.evaluate_with_adaptive_batch_size(
-            model=model, batch_size=batch_size, x=dataset, **kwargs
+            model=model, batch_size=batch_size, x=dataset, verbose=verbose, **kwargs
         )
 
     def export_model(self):
diff --git a/autokeras/engine/tuner.py b/autokeras/engine/tuner.py
--- a/autokeras/engine/tuner.py
+++ b/autokeras/engine/tuner.py
@@ -134,7 +134,14 @@ def get_output_layer(tensor):
                 layer = get_output_layer(layer.output)
         return model
 
-    def search(self, epochs=None, callbacks=None, validation_split=0, **fit_kwargs):
+    def search(
+        self,
+        epochs=None,
+        callbacks=None,
+        validation_split=0,
+        verbose=1,
+        **fit_kwargs
+    ):
         """Search for the best HyperParameters.
 
         If there is not early-stopping in the callbacks, the early-stopping callback
@@ -178,7 +185,9 @@ def search(self, epochs=None, callbacks=None, validation_split=0, **fit_kwargs):
         self.hypermodel.build(hp)
         self.oracle.update_space(hp)
 
-        super().search(epochs=epochs, callbacks=new_callbacks, **fit_kwargs)
+        super().search(
+            epochs=epochs, callbacks=new_callbacks, verbose=verbose, **fit_kwargs
+        )
 
         # Train the best model use validation data.
         # Train the best model with enough number of epochs.
diff --git a/autokeras/utils/utils.py b/autokeras/utils/utils.py
--- a/autokeras/utils/utils.py
+++ b/autokeras/utils/utils.py
@@ -63,18 +63,22 @@ def contain_instance(instance_list, instance_type):
     return any([isinstance(instance, instance_type) for instance in instance_list])
 
 
-def evaluate_with_adaptive_batch_size(model, batch_size, **fit_kwargs):
+def evaluate_with_adaptive_batch_size(model, batch_size, verbose=1, **fit_kwargs):
     return run_with_adaptive_batch_size(
         batch_size,
-        lambda x, validation_data, **kwargs: model.evaluate(x, **kwargs),
+        lambda x, validation_data, **kwargs: model.evaluate(
+            x, verbose=verbose, **kwargs
+        ),
         **fit_kwargs
     )
 
 
-def predict_with_adaptive_batch_size(model, batch_size, **fit_kwargs):
+def predict_with_adaptive_batch_size(model, batch_size, verbose=1, **fit_kwargs):
     return run_with_adaptive_batch_size(
         batch_size,
-        lambda x, validation_data, **kwargs: model.predict(x, **kwargs),
+        lambda x, validation_data, **kwargs: model.predict(
+            x, verbose=verbose, **kwargs
+        ),
         **fit_kwargs
     )
 


Test patch: