autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.62k stars 270 forks source link

Functional model support for hidden_layers #437

Closed snmsc closed 4 years ago

snmsc commented 4 years ago

1) I think Talos should add

According to

https://spectrum.chat/talos/general/the-documentation-on-the-hidden-layer-seems-less-verbose-how-do-we-use-it-in-a-keras-functional-api-context-from-this-https-github-com-autonomio-talos-blob-master-examples-hyperparameter-20optimization-20on-20keras-20with-20breast-20cancer-20data-ipynb-example-i-see-that-you-can-select-the-number-of-hidden-layers-as-a-parameter-but-how-can-we-select-the-number-of-nodes-in-that-layer-and-optimize-other-parameters-thanks~c2944443-98d5-4347-ad18-a6ef7b31bd94

hidden_layers() currently only supports sequential, but not functional models. I think it's a really cool feature and it would be great if it could support functional models.

2) Once implemented, I can see how this feature will

Researchers writing functional models could make their models more concise/write models faster if hidden_layers() would support functional models.

3) I believe this feature is

4) Given the chance, I'd be happy to make a PR for this feature


github-actions[bot] commented 4 years ago

Welcome to Talos community! Thanks so much for creating your first issue :)

erelin6613 commented 4 years ago

Thanks for cool lib though I agree, functional model support should be there too. I tried myself to use Scan(..., functional_model=True) function but got an error: TypeError: __init__() got an unexpected keyword argument 'functional_model'. According to the docs on https://autonomio.github.io, it should be an option. I looked actual code but could not find any references.

mikkokotila commented 4 years ago

Talos definitely supports functional models. See this example in the docs. The docs in https://autonomio.github.io are depreciated.

For hidden layers, I suggest that you just do it in the input model itself as you like. For example:

for i in range(params['hidden_layers']):
  model.add(Dense(params['hidden_layer_neurons']))
  model.add(Dropout(params['hidden_layer_dropout']))

I strongly recommend using this approach for all cases.

Closing here.