The logic is that if one LSTM layer is added then its return sequence must be False, whereas if two LSTM layers are to be added the first one should have return sequence equal to True.
I'm trying to do this by using parent_values but it does not work, so far I have something like this:
use_two_lstm_layers = hp.Boolean("use_two_lstm_layers")
return_sequences = hp.Choice("return_sequences", ['True', 'False'], parent_values=True)
model.add(keras.layers.Bidirectional(tf.keras.layers.LSTM(units=hp.Int('units', min_value=8, max_value=64, step=8), return_sequences=return_sequences)))
model.add(keras.layers.Dropout(rate=hp.Float('dp', min_value=0.1, max_value=0.8, step=0.1)))
if use_two_lstm_layers:
model.add(keras.layers.Bidirectional(tf.keras.layers.LSTM(units=hp.Int('units2', min_value=8, max_value=256, step=8))))
model.add(keras.layers.Dropout(rate=hp.Float('dp2', min_value=0.1, max_value=0.8, step=0.1)))
I would expect this to follow the previous logic but it doesn't and I end up with dim issues. What's the solution?
source https://stackoverflow.com/questions/74933711/how-to-use-hyperband-to-tune-for-single-or-multiple-lstm-layers
Comments
Post a Comment