How to handle variable number of layers?
ben-arnao opened this issue · 0 comments
ben-arnao commented
Is there a good way to make # of layers a parameter?
I noticed if i do something like the following
def build_fn(input_shape):
model = Sequential([
Dense(Integer(50, 150), input_shape=input_shape, activation='relu'),
Dropout(Real(0.2, 0.7)),
])
for x in range(Integer(0, 10)):
model.add(Dense(Integer(50, 150), activation='relu'))
model.add(Dropout(Real(0.2, 0.7)))
model.add(Dense(1, activation=Categorical(['sigmoid', 'softmax'])))
model.compile(
optimizer='adam',
loss='binary_crossentropy', metrics=['accuracy']
)
return model
Results in an error TypeError: 'Integer' object cannot be interpreted as an integer
However i think this a more fundamental question as to how multiple layers are handled. The experiment will have a different number of parameters based on how much layers are chosen.