Skip to content

Commit

Permalink
adding keras verbosity argument
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbattey committed Sep 27, 2020
1 parent d415ff1 commit e32ae60
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scripts/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
help='Path to a _params.json file to load parameters from a previous run.\
Parameters from the json file will supersede all parameters provided \
via command line.')
parser.add_argument('--keras_verbose',default=1,type=int,
help='verbose argument passed to keras in model training. \
0 = silent. 1 = progress bars for minibatches. 2 = show epochs. \
Yes, 1 is more verbose than 2. Blame keras. \
default: 1. ')
args=parser.parse_args()

#set seed and gpu
Expand Down Expand Up @@ -234,15 +239,15 @@ def load_callbacks(boot):
if args.bootstrap or args.jacknife:
checkpointer=tf.keras.callbacks.ModelCheckpoint(
filepath=args.out+"_boot"+str(boot)+"_weights.hdf5",
verbose=1,
verbose=args.keras_verbose,
save_best_only=True,
save_weights_only=True,
monitor="val_loss",
period=1)
else:
checkpointer=tf.keras.callbacks.ModelCheckpoint(
filepath=args.out+"_weights.hdf5",
verbose=1,
verbose=args.keras_verbose,
save_best_only=True,
save_weights_only=True,
monitor="val_loss",
Expand All @@ -253,7 +258,7 @@ def load_callbacks(boot):
reducelr=tf.keras.callbacks.ReduceLROnPlateau(monitor='val_loss',
factor=0.5,
patience=int(args.patience/6),
verbose=1,
verbose=args.keras_verbose,
mode='auto',
min_delta=0,
cooldown=0,
Expand All @@ -265,7 +270,7 @@ def train_network(model,traingen,testgen,trainlocs,testlocs):
epochs=args.max_epochs,
batch_size=args.batch_size,
shuffle=True,
verbose=1,
verbose=args.keras_verbose,
validation_data=(testgen,testlocs),
callbacks=[checkpointer,earlystop,reducelr])
if args.bootstrap or args.jacknife:
Expand Down

0 comments on commit e32ae60

Please sign in to comment.