Skip to content

Commit

Permalink
Merge pull request #759 from ufal/final-saving
Browse files Browse the repository at this point in the history
Saving of variables upon finish
  • Loading branch information
jindrahelcl committed Sep 19, 2018
2 parents aabfc26 + 1baba63 commit 98d9db9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion neuralmonkey/experiment.py
Expand Up @@ -185,7 +185,8 @@ def train(self) -> None:
postprocess=self.model.postprocess,
train_start_offset=self.model.train_start_offset,
runners_batch_size=self.model.runners_batch_size,
initial_variables=self.model.initial_variables)
initial_variables=self.model.initial_variables,
final_variables=self.get_path("variables.data.final"))

self._vars_loaded = True

Expand Down
4 changes: 4 additions & 0 deletions neuralmonkey/learning_utils.py
Expand Up @@ -39,6 +39,7 @@ def training_loop(tf_manager: TensorFlowManager,
log_directory: str,
evaluators: EvalConfiguration,
runners: List[BaseRunner],
final_variables: str,
train_dataset: Dataset,
val_dataset: Union[Dataset, List[Dataset]],
test_datasets: Optional[List[Dataset]] = None,
Expand Down Expand Up @@ -286,6 +287,9 @@ def training_loop(tf_manager: TensorFlowManager,
.format(main_metric, tf_manager.best_score,
tf_manager.best_score_epoch))

log("Saving final variables in {}".format(final_variables))
tf_manager.save(final_variables)

if test_datasets:
tf_manager.restore_best_vars()

Expand Down
2 changes: 1 addition & 1 deletion neuralmonkey/tf_manager.py
Expand Up @@ -88,7 +88,7 @@ def __init__(self,
init_op = tf.global_variables_initializer()
for sess in self.sessions:
sess.run(init_op)
self.saver = tf.train.Saver(max_to_keep=self.saver_max_to_keep,
self.saver = tf.train.Saver(max_to_keep=None,
var_list=[g for g in tf.global_variables()
if "reward_" not in g.name])

Expand Down

0 comments on commit 98d9db9

Please sign in to comment.