Skip to content
Advertisement

How to hypertune input shape using keras tuner?

I am trying to hypertune the input shape of an LSTM model based on the different values of timesteps. However, I am facing an issue. While initializing the model, the default value of timesteps (which is 2) is chosen, and accordingly, the build_model.scaled_train is created of shape (4096, 2, 64). Thus the value of input_shape during initialization is (2, 64). When the training starts and the value of timesteps is arbitrarily chosen as 16, then build_model.scaled_train has shape (512, 16, 64). This means that input_shape now takes the value (16, 64). However, this is not reflected in the model. The InputLayer retains the shape (2, 64) it got during initialization. Hence, an error – Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 16, 64), found shape=(None, 2, 64).

JavaScript

When I start hyperparameter tuning, this happens.

JavaScript

Error –

JavaScript

I think I am making a logical mistake somewhere but cannot find it. Please help.

Advertisement

Answer

I made some changes which are written below and it worked fine. But I don’t know if it is the optimal solution.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement