You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to Keras Tuner, so apologies if this is simply a user error.
I'm trying to build a model with a time distributed layer, followed by several LSTM layers followed by dense layers, with various parameters defined using hp.Int, hp.Choice, etc. My model builder code is as follows.
import kerastuner as kt
def model_builder(hp):
inputs = Input(shape=(40, 136)) #full tensor
x = inputs
#prepare hyperparameter tuning
num_LSTM_layers = hp.Int('num_LSTM_layers',0,3)
num_LSTM_units=[]
for i in range(num_LSTM_layers):
num_LSTM_units.append(hp.Int('lstm'+str(i+1)+'_units',
min_value = 32,
max_value = 64,
step=8))
num_dense_layers = hp.Int('num_dense_layers',1,3)
num_dense_units = []
dense_activation = []
for i in range(num_dense_layers):
num_dense_units.append(hp.Int('dense'+str(i+1)+'_units',
min_value = 32,
max_value = 128,
step=16))
dense_activation.append(hp.Choice("dense"+str(i+1)+"_activation",["relu", "leaky_relu"]))
hp_learning_rate = hp.Choice('learning_rate', values=[1e-3, 1e-2])
#make the NN
x = TimeDistributed(Dense(hp.Int('td_dense_units',min_value=32,max_value=128,step=16),activation=hp.Choice("td_dense_activation",["relu","leaky_relu"])))(x)
for i in range(num_LSTM_layers):
x = LSTM(num_LSTM_units[i],return_sequences=True if i<num_LSTM_layers else False)(x)
for i in range(num_dense_layers):
x = Dense(num_dense_units[i],activation = dense_activation[i])(x)
output = Dense(1,activation='relu',name="Elo")(x)
model = keras.Model(inputs=inputs,outputs=[output])
model.compile(optimizer=keras.optimizers.Adam(learning_rate=hp_learning_rate),
loss={'Elo':'mae'},
metrics={'Elo':'mae'})
return model
As you can see, I have, for example 3 dense layers, but no hyperparameters for these are shown. Instead, the hyperparameters shown are for the values generated in trial 1 (i.e., in that trial I had 2 LSTM layers and 1 dense layer rather than the 3 I'm supposed to have in this trial).
The text was updated successfully, but these errors were encountered:
Here's an example that (perhaps) better illustrates the issue. In my first trial there should be 3 LSTM layers and 2 dense layers, but parameters are only shown for 1 dense layer and 1 lstm layer:
I'm new to Keras Tuner, so apologies if this is simply a user error.
I'm trying to build a model with a time distributed layer, followed by several LSTM layers followed by dense layers, with various parameters defined using hp.Int, hp.Choice, etc. My model builder code is as follows.
When I run the model using the following
I get output as follows:
As you can see, I have, for example 3 dense layers, but no hyperparameters for these are shown. Instead, the hyperparameters shown are for the values generated in trial 1 (i.e., in that trial I had 2 LSTM layers and 1 dense layer rather than the 3 I'm supposed to have in this trial).
The text was updated successfully, but these errors were encountered: