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

conditional_scope might not be correctly exemplified. #924

Open
scrovy opened this issue Aug 16, 2023 · 0 comments
Open

conditional_scope might not be correctly exemplified. #924

scrovy opened this issue Aug 16, 2023 · 0 comments

Comments

@scrovy
Copy link

scrovy commented Aug 16, 2023

This code does not illustrate the utility of conditional_scope according to what is described above it. Since no hyperparameters are created within the with hp.conditional_scope("model_type", ...): scopes, the code will behave the same as if the scopes were not there at all. Could you either improve the code by inserting some hp.Int, hp.Choice, etc to the body of the scopes or clarify if I misunderstood the expected behavior of conditional_scope? Thanks in advance.

```python
def MyHyperModel(HyperModel):
def build(self, hp):
model = Sequential()
model.add(Input(shape=(32, 32, 3)))
model_type = hp.Choice("model_type", ["mlp", "cnn"])
with hp.conditional_scope("model_type", ["mlp"]):
if model_type == "mlp":
model.add(Flatten())
model.add(Dense(32, activation='relu'))
with hp.conditional_scope("model_type", ["cnn"]):
if model_type == "cnn":
model.add(Conv2D(64, 3, activation='relu'))
model.add(GlobalAveragePooling2D())
model.add(Dense(10, activation='softmax'))
return model
```

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