Skip to content

Commit

Permalink
♻️ remove input/embedding dropout rates
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGiorgi committed Aug 20, 2019
1 parent 6a49bac commit 4066075
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion saber/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ decay = 0.0
# Three dropout values must be specified (separated by a comma), corresponding to the dropout rate
# to apply to the input, output and recurrent connections respectively. Must be a value between 0.0
# and 1.0.
dropout_rate = 0.3, 0.3, 0.1
dropout_rate = 0.1

batch_size = 32

Expand Down
15 changes: 3 additions & 12 deletions saber/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _parse_config_args(self, config):
args['learning_rate'] = config['training'].getfloat('learning_rate')
args['decay'] = config['training'].getfloat('decay')
args['grad_norm'] = config['training'].getfloat('grad_norm')
args['dropout_rate'] = config['training']['dropout_rate'].split(',')
args['dropout_rate'] = config['training'].getfloat('dropout_rate')
args['batch_size'] = config['training'].getint('batch_size')
args['validation_split'] = config['training'].getfloat('validation_split')
args['k_folds'] = config['training'].getint('k_folds')
Expand Down Expand Up @@ -206,12 +206,6 @@ def _post_process_config_args(self, args):
args['output_folder'] = generic_utils.clean_path(args['output_folder'])
if args['pretrained_model'] and args['pretrained_model'] not in PRETRAINED_MODELS:
args['pretrained_model'] = generic_utils.clean_path(args['pretrained_model'])
# build dictionary for dropout rates
args['dropout_rate'] = {
'input': float(args['dropout_rate'][0]),
'output': float(args['dropout_rate'][1]),
'recurrent': float(args['dropout_rate'][2]),
}

return args

Expand Down Expand Up @@ -254,11 +248,8 @@ def _parse_cli_args(self):
parser.add_argument('--decay', required=False, type=float,
help=('float >= 0. Learning rate decay over each update. Note that for '
'certain optimizers this value is ignored. Defaults to 0.'))
parser.add_argument('--dropout_rate', required=False, nargs=3, type=float,
metavar=('input', 'output', 'recurrent'),
help=('Expects three values, separated by a space, which specify the '
'fraction of units to drop for input, output and recurrent '
'connections respectively. Values must be between 0 and 1.'))
parser.add_argument('--dropout_rate', required=False, type=float,
help='float between 0 and 1. Fraction of the input units to drop.')
parser.add_argument('--grad_norm', required=False, type=float,
help='Tau threshold value for gradient normalization, defaults to 1.')
parser.add_argument('--k_folds', required=False, type=int,
Expand Down
8 changes: 4 additions & 4 deletions saber/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
'pubmed&id=')
# CONFIG
CONFIG_ARGS = ['model_name', 'save_model', 'dataset_folder', 'output_folder',
'pretrained_model', 'word_embed_dim', 'char_embed_dim', 'optimizer', 'activation',
'learning_rate', 'decay', 'grad_norm', 'dropout_rate', 'batch_size', 'k_folds',
'epochs', 'criteria', 'verbose', 'debug', 'save_all_weights', 'tensorboard',
'replace_rare_tokens', 'variational_dropout', 'validation_split', 'dataset_reader']
'pretrained_model', 'optimizer', 'activation', 'learning_rate', 'decay', 'grad_norm',
'dropout_rate', 'batch_size', 'k_folds', 'epochs', 'criteria', 'verbose', 'debug',
'save_all_weights', 'tensorboard', 'replace_rare_tokens', 'validation_split',
'dataset_reader']
8 changes: 4 additions & 4 deletions saber/tests/resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
'learning_rate': '0.0',
'grad_norm': '1.0',
'decay': '0.0',
'dropout_rate': '0.3, 0.3, 0.1',
'dropout_rate': '0.1',
'batch_size': '32',
'validation_split': '0.0',
'k_folds': '2',
Expand Down Expand Up @@ -143,7 +143,7 @@
'learning_rate': 0.0,
'decay': 0.0,
'grad_norm': 1.0,
'dropout_rate': {'input': 0.3, 'output': 0.3, 'recurrent': 0.1},
'dropout_rate': 0.1,
'batch_size': 32,
'validation_split': 0.0,
'k_folds': 2,
Expand All @@ -162,7 +162,7 @@
'grad_norm': 1.0,
'learning_rate': 0.05,
'decay': 0.5,
'dropout_rate': [0.6, 0.6, 0.2],
'dropout_rate': 0.6,
# the datasets are used for test purposes so they must
# point to the correct resources, this can be ensured by passing their
# paths here
Expand All @@ -181,7 +181,7 @@
'learning_rate': 0.05,
'decay': 0.5,
'grad_norm': 1.0,
'dropout_rate': {'input': 0.6, 'output': 0.6, 'recurrent': 0.2},
'dropout_rate': 0.6,
'batch_size': 32,
'validation_split': 0.0,
'k_folds': 2,
Expand Down
2 changes: 1 addition & 1 deletion saber/tests/resources/dummy_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ decay = 0.0
# Three dropout values must be specified (separated by a comma), corresponding to the dropout rate
# to apply to the input, output and recurrent connections respectively. Must be a value between 0.0
# and 1.0.
dropout_rate = 0.3, 0.3, 0.1
dropout_rate = 0.1

batch_size = 32

Expand Down

0 comments on commit 4066075

Please sign in to comment.