-
Notifications
You must be signed in to change notification settings - Fork 401
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Here is my script to replicate the example from the description on the project pypi page
import keras_tuner
from tensorflow import keras
import numpy as np
import tensorflow as tf
def build_model(hp):
model = keras.Sequential()
model.add(keras.layers.Dense(
hp.Choice('units', [8, 16, 32]),
activation='relu'))
model.add(keras.layers.Dense(1, activation='relu'))
model.compile(loss='mse')
return model
tuner = keras_tuner.RandomSearch(
build_model,
objective='val_loss',
max_trials=5)
x_train = tf.random.normal((1, 300, 300, 3))
y_train = tf.random.normal((1, 300, 300, 3))
x_val = tf.random.normal((1, 300, 300, 3))
y_val = tf.random.normal((1, 300, 300, 3))
tuner.search(x_train, y_train, epochs=5, validation_data=(x_val, y_val))
best_model = tuner.get_best_models()[0]
This leads to the error
keras_tuner.src.errors.FatalTypeError: Expected the model-building function, or HyperModel.build() to return a valid Keras Model instance. Received: <tf_keras.src.engine.sequential.Sequential object at 0x7f08feadffa0> of type <class 'tf_keras.src.engine.sequential.Sequential'>.
Tensorflow is used from docker image https://docs.nvidia.com/deeplearning/frameworks/tensorflow-release-notes/rel-24-06.html
It includes tensorflow 2.16.1
keras-tuner version is 1.4.7
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working