-1

I have been trying to use Keras tuner for a Keras model built by my collegues (apologies, I am a pytorch user) and when I apply Keras tuner to this model I get AttributeError: 'HyperParameters' object has no attribute 'shape'

def my_function(hp, input_size: int, dense_spec: dict):
    inp = tf.keras.layers.Input((input_size,))
    x = inp
    for units_val in dense_spec:
        x = tf.keras.layers.Dense(units=hp.Int('units_' + str(units_val), min_value=16, max_value=units_val, step=16, default=units_val), activation="relu") (x)

    x = tf.keras.layers.Lambda(
    lambda tensor: K.l2_normalize(tensor, axis=1), name="vector"
)(x)

model0 = tf.keras.models.Model(inp, x, name="model0")
return model0
JohnJ
  • 6,736
  • 13
  • 49
  • 82

1 Answers1

0

I doubt this is the answer but on your line...

    for units_val in dense_spec:
        x = tf.keras.layers.Dense(units=hp.Int('units_' + str(units_val), min_value=16, max_value=units_val, step=16, default=units_val), activation="relu") (x)

There is an extra space before (x) at the end of line.

i.e.

You Have >>> ...activation="relu") (x)
You Want >>> ...activation="relu")(x)
Darien Schettler
  • 546
  • 4
  • 13