(
        X_train,
        X_test,
        height,
        width,
        num_classes,
        patience=1,
        executions_per_trial=1,
        seed=42,
        max_trials=3,
        objective='val_accuracy',
        directory='my_dir',
        epochs=10,
        verbose=0,
        test_size=0.2)
return tuner.get_best_models(1)[0], hyp, history
Return:
        models[0] : best model obtained after tuning
        best_hps : best Hyperprameters obtained after tuning, stored as array
        history : history of the data executed from the given model
Return:
        models[0] : best model obtained after tuning
        best_hps : best Hyperprameters obtained after tuning, stored as array
        history : history of the data executed from the given model
Return : models [ 0 ] : best model obtained after tuning best_hps : best Hyperprameters obtained after tuning stored as array history : history of the data executed from the given model
def tuneCNN(
        X_train,
        X_test,
        height,
        width,
        num_classes,
        patience=1,
        executions_per_trial=1,
        seed=42,
        max_trials=3,
        objective='val_accuracy',
        directory='my_dir',
        epochs=10,
        verbose=0,
        test_size=0.2):
    # creates hypermodel object based on the num_classes and the input shape
    hypermodel = CNNHyperModel(input_shape=(
        height, width, 3), num_classes=num_classes)

    # # tuners, establish the object to look through the tuner search space
    tuner = RandomSearch(
        hypermodel,
        objective=objective,
        seed=seed,
        max_trials=max_trials,
        executions_per_trial=executions_per_trial,
        directory=directory,
    )


    # searches the tuner space defined by hyperparameters (hp) and returns the
    # best model

    tuner.search(X_train,
                 validation_data=X_test,
                 callbacks=[tf.keras.callbacks.EarlyStopping(patience=patience)],
                 epochs=epochs,
                 verbose=verbose)

    # best hyperparamters
    hyp = tuner.get_best_hyperparameters(num_trials=1)[0]
    #hyp = tuner.oracle.get_best_trials(num_trials=1)[0].hyperparameters.values
    #best_hps = np.stack(hyp).astype(None)
    history = tuner_hist(
        X_train,
        X_test,
        tuner,
        hyp,
        img=1,
        epochs=epochs,
        verbose=verbose,
        test_size=test_size)

    """
    Return:
        models[0] : best model obtained after tuning
        best_hps : best Hyperprameters obtained after tuning, stored as array
        history : history of the data executed from the given model
    """
    return tuner.get_best_models(1)[0], hyp, history
def tuneCNN ( X_train , X_test , height , width , num_classes , patience = 1 , executions_per_trial = 1 , seed = 42 , max_trials = 3 , objective = 'val_accuracy' , directory = 'my_dir' , epochs = 10 , verbose = 0 , test_size = 0.2 ) : # creates hypermodel object based on the num_classes and the input shape hypermodel = CNNHyperModel ( input_shape = ( height , width , 3 ) , num_classes = num_classes ) # # tuners, establish the object to look through the tuner search space tuner = RandomSearch ( hypermodel , objective = objective , seed = seed , max_trials = max_trials , executions_per_trial = executions_per_trial , directory = directory , ) # searches the tuner space defined by hyperparameters (hp) and returns the # best model tuner . search ( X_train , validation_data = X_test , callbacks = [ tf . keras . callbacks . EarlyStopping ( patience = patience ) ] , epochs = epochs , verbose = verbose ) # best hyperparamters hyp = tuner . get_best_hyperparameters ( num_trials = 1 ) [ 0 ] #hyp = tuner.oracle.get_best_trials(num_trials=1)[0].hyperparameters.values #best_hps = np.stack(hyp).astype(None) history = tuner_hist ( X_train , X_test , tuner , hyp , img = 1 , epochs = epochs , verbose = verbose , test_size = test_size ) return tuner . get_best_models ( 1 ) [ 0 ] , hyp , history