GraphAutoModel class

    inputs, outputs, name="graph_auto_model", max_trials=100, directory=None, objective="val_loss", seed=None

A HyperModel defined by a graph of HyperBlocks.

GraphAutoModel is a subclass of HyperModel. Besides the HyperModel properties, it also has a tuner to tune the HyperModel. The user can use it in a similar way to a Keras model since it also has fit() and predict() methods.

The user can specify the high-level neural architecture by connecting the HyperBlocks with the functional API, which is the same as the Keras functional API.


  • inputs: A list of or a HyperNode instances. The input node(s) of the GraphAutoModel.
  • outputs: A list of or a HyperNode instances. The output node(s) of the GraphAutoModel.
  • name: String. The name of the AutoModel. Defaults to 'graph_auto_model'.
  • max_trials: Int. The maximum number of different Keras Models to try. The search may finish before reaching the max_trials. Defaults to 100.
  • directory: String. The path to a directory for storing the search outputs. Defaults to None, which would create a folder with the name of the AutoModel in the current directory.
  • objective: String. Name of model metric to minimize or maximize, e.g. 'val_accuracy'. Defaults to 'val_loss'.
  • seed: Int. Random seed.


fit method
    x=None, y=None, epochs=None, callbacks=None, validation_split=0, validation_data=None, **kwargs

Search for the best model and hyperparameters for the AutoModel.

It will search for the best model based on the performances on validation data.


  • x: numpy.ndarray or tensorflow.Dataset. Training data x.
  • y: numpy.ndarray or tensorflow.Dataset. Training data y.
  • epochs: Int. The number of epochs to train each model during the search. If unspecified, by default we train for a maximum of 1000 epochs, but we stop training if the validation loss stops improving for 10 epochs (unless you specified an EarlyStopping callback as part of the callbacks argument, in which case the EarlyStopping callback you specified will determine early stopping).
  • callbacks: List of Keras callbacks to apply during training and validation.
  • validation_split: Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, will not train on it, and will evaluate the loss and any model metrics on this data at the end of each epoch. The validation data is selected from the last samples in the x and y data provided, before shuffling. This argument is not supported when x is a dataset. The best model found would be fit on the entire dataset including the validation data.
  • validation_data: Data on which to evaluate the loss and any model metrics at the end of each epoch. The model will not be trained on this data. validation_data will override validation_split. The type of the 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.
  • **kwargs: Any arguments supported by


predict method

GraphAutoModel.predict(x, batch_size=32, **kwargs)

Predict the output for a given testing data.


  • x: Any allowed types according to the input node. Testing data.
  • batch_size: Int. Defaults to 32.
  • **kwargs: Any arguments supported by keras.Model.predict.


A list of numpy.ndarray objects or a single numpy.ndarray. The predicted results.