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

Advanced hyperparameter configuration #591

Open
david-thrower opened this issue Aug 17, 2022 · 1 comment
Open

Advanced hyperparameter configuration #591

david-thrower opened this issue Aug 17, 2022 · 1 comment

Comments

@david-thrower
Copy link

david-thrower commented Aug 17, 2022

1) I recommend:

To talos.Scan(), add a parameter:
"hyperparameter_config": for example, a dictionary in the format:

KEY: 'name of hyperparameter as listed in talos.Scan(params)' ;

VALUE: list of dictionaries, one dict for each config option for the hyperparameter named in the key, to add additional options like what np.choice offers (e.g size argument allowing an array of selections from a given param, and an option for selection [with | w/o] replacement).

Example:

params =\
    {'l4_upstream_conn_index':
        np.arange(1,3).tolist(),
     'l5_upstream_conn_index':
        np.arange(1,4).tolist(),
     'l6_upstream_conn_index':
        np.arange(1,5)).tolist(),
     'l7_upstream_conn_index':
        np.arange(1,6).tolist()}

param_options = {

    'l4_upstream_conn_index':[
        {'size':3},
        { 'with_replacement':1}],  # Select 3 elements with replacement from l4_upstream_conn_index 

    'l5_upstream_conn_index':[
        {'size':4},
        { 'with_replacement':1}] , # Select 4 elements with replacement from l5_upstream_conn_index
# ...
}

def make_skip_connection_model(params)

    layers = np.ones(7).tolist()
    
    layers[0] = Input((5,))

    layers[1] = Dense(7)(layers[0] ) 
    layers[2] = Dense(7)(layers[1] ) 
    layers[3] = Dense(7)(layers[2] ) 

    for i in np.arange(4,8):
        layers[i] =\
            Dense(
                Concatenate([layers[c]) 
                                          for c in params[f'l{i}_upstream_conn_index'']],
                                           axis=1)
            )  # To make the skip connections to myltiple predecessor layers, this needs to make multiple selections from this parameter...

        out_layer = Dense(1,'sigmoid')(layers[-1])
        model = Model(inputs=layers[0],
                                 outputs=out_layer)

        model.compile(...)
        results = model.fit(...)
        
        return results, model 
talos.scan(model=make_skip_connection_model,
                 params = params,
                 hyperparameter_config = param_options)

@mikkokotila
Copy link
Contributor

From the example, is not completely clear why would you not do this same just by adding the variety you want in the parameter dictionary i.e. why does it have to be outside of it the way things are implemented currently?

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

No branches or pull requests

2 participants