Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic example of pypi page not working #1027

Open
abhinavdhere opened this issue Oct 1, 2024 · 0 comments
Open

Basic example of pypi page not working #1027

abhinavdhere opened this issue Oct 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@abhinavdhere
Copy link

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

@abhinavdhere abhinavdhere added the bug Something isn't working label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant