Created
November 8, 2019 04:57
-
-
Save analyticsindiamagazine/6dccce00204c42d1f19aca716edd7b87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Training the model for each combination of the hyperparameters. | |
| x_train = X_train | |
| x_test, y_test = X_val , y_val | |
| #A unique number for each training session | |
| session_num = 0 | |
| #Nested for loop training with all possible combinathon of hyperparameters | |
| for num_units in HP_NUM_UNITS.domain.values: | |
| for dropout_rate in tf.linspace(HP_DROPOUT.domain.min_value,HP_DROPOUT.domain.max_value,3): | |
| for optimizer in HP_OPTIMIZER.domain.values: | |
| hparams = { | |
| HP_NUM_UNITS: num_units, | |
| HP_DROPOUT: float("%.2f"%float(dropout_rate)), # float("%.2f"%float(dropout_rate)) limits the decimal palces to 2 | |
| HP_OPTIMIZER: optimizer, | |
| } | |
| run_name = "run-%d" % session_num | |
| print('--- Starting trial: %s' % run_name) | |
| print({h.name: hparams[h] for h in hparams}) | |
| run('logs/hparam_tuning/' + run_name, hparams) | |
| session_num += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment