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

Reload weights after plateau #3245

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Dockerfile.train
doc/xml-c
doc/xml-java
doc/xml-dotnet
convert_graphdef_memmapped_format
5 changes: 4 additions & 1 deletion training/mozilla_voice_stt_training/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .evaluate import evaluate
from six.moves import zip, range
from .util.config import Config, initialize_globals
from .util.checkpoints import load_or_init_graph_for_training, load_graph_for_evaluation
from .util.checkpoints import load_or_init_graph_for_training, load_graph_for_evaluation, reload_best_checkpoint
from .util.evaluate_tools import save_samples_json
from .util.feeding import create_dataset, audio_to_features, audiofile_to_features
from .util.flags import create_flags, FLAGS
Expand Down Expand Up @@ -645,6 +645,9 @@ def __call__(self, progress, data, **kwargs):
log_info('Encountered a plateau, reducing learning rate to {}'.format(
current_learning_rate))

# Reload checkpoint that we use the best_dev weights again
reload_best_checkpoint(session)

if FLAGS.metrics_files:
# Read only metrics, not affecting best validation loss tracking
for source, init_op in zip(metrics_sources, metrics_init_ops):
Expand Down
4 changes: 4 additions & 0 deletions training/mozilla_voice_stt_training/util/checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def _load_or_init_impl(session, method_order, allow_drop_layers):
sys.exit(1)


def reload_best_checkpoint(session):
_load_or_init_impl(session, ['best'], allow_drop_layers=False)


def load_or_init_graph_for_training(session):
'''
Load variables from checkpoint or initialize variables. By default this will
Expand Down