Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle variable number of layers? #182

Open
ben-arnao opened this issue Aug 9, 2019 · 0 comments
Open

How to handle variable number of layers? #182

ben-arnao opened this issue Aug 9, 2019 · 0 comments

Comments

@ben-arnao
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant