You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defconstruct_best_network(model_file, trial_glob):
""" Constructs the best-performing model according to the supplied hyperparameter optimization trials, and populates the parameters with the provided model file. Parameters ---------- model_file : str Path to h5 file holding the parameters for this model. trial_glob : str Glob of h5 trial files. Returns ------- layers : list of lasagne.layers.Layer Layers comprising the model. """# Load in all parameter optimization trialstrial_files=glob.glob(trial_glob)
trials= [deepdish.io.load(f) forfintrial_files]
# Ignore trials with NaN objectivetrials= [tfortintrialsifnotnp.isnan(t['best_objective'])]
# Get the hyperparameters for the trial with the lowest objective valuebest_trial=sorted(trials, key=lambdat: t['best_objective'])[0]
hyperparameters=best_trial['hyperparameters']
# Load in the pre-trained parameters for the best performing modelsnetwork_params=deepdish.io.load(model_file)
# Create dictionary mapping network structure names to build functionsbuild_network= {
'pse_big_filter': build_pse_net_big_filter,
'pse_small_filters': build_pse_net_small_filters,
'dhs_big_filter': build_pse_net_big_filter,
'dhs_small_filters': build_pse_net_small_filters}
# PSE and DHS nets have different hyperparameters, so we must construct# kwargs based on what appears in hyperparameterskwargs= {
# PSE trials do not have this hyperparameter by default, so as in# experiment_utils.run_trial, we must set the default value'downsample_frequency': hyperparameters.get('downsample_frequency', 1)}
if'n_attention'inhyperparameters:
kwargs['n_attention'] =hyperparameters['n_attention']
if'n_conv'inhyperparameters:
kwargs['n_conv'] =hyperparameters['n_conv']
layers=build_network(
(None, 1, None, feature_extraction.N_NOTES),
# We will supply placeholders here but load in the values belownp.zeros((1, feature_extraction.N_NOTES), theano.config.floatX),
np.ones((1, feature_extraction.N_NOTES), theano.config.floatX),
**kwargs)
# Load in network parameter valueslasagne.layers.set_all_param_values(
layers[-1], network_params['X'])
returnlayers
Would be used in precompute.py for a few of the experiments, and in match.py.
The text was updated successfully, but these errors were encountered:
Would look something like this:
Would be used in
precompute.py
for a few of the experiments, and inmatch.py
.The text was updated successfully, but these errors were encountered: