0

I have a simple use case, but I cannot find any solution to this problem anywhere: I have two hyperparameters which I want to tune with keras-tuner:

  1. Amount of nodes of the first hidden layer
  2. Amount of nodes of the second hidden layer

Now, I want to the amount of nodes of the second hidden layer to not exceed the amount of the first one and have at least 60% of the amount of the first one.
I tried different options, but all fail and I get for some reason always 30 for the second one:

first_layer_nodes = hp.Int(name='first_layer_nodes',min_value = 50, max_value=300,step=32)
second_layer_nodes = hp.Int(name='second_layer_nodes',min_value = int(first_layer_nodes*0.6), max_value=first_layer_nodes, step = 32)

or

first_layer_nodes = hp.Int(name='first_layer_nodes',min_value = 50, max_value=300,step=32)
second_layer_nodes = hp.Int(name='second_layer_nodes',min_value = int(hp.get('first_layer_nodes')*0.6), max_value=hp.get('first_layer_nodes'), step = 32)

How can I accomplish this?

Code Pope
  • 5,075
  • 8
  • 26
  • 68

0 Answers0