3578019be301ae9d8e9b7518daa5fb113d00d2db,open_seq2seq/utils/hooks.py,RunEvaluationHook,after_run,#RunEvaluationHook#Any#Any#,147
Before Change
inputs_per_batch, outputs_per_batch = [], []
total_loss = 0.0
for cnt, feed_dict in enumerate(
self._model.data_layer.iterate_one_epoch(cross_over=True)
):
loss, inputs, outputs = run_context.session.run(
self._fetches, feed_dict,
)
inputs_per_batch.append(inputs)
outputs_per_batch.append(outputs)
total_loss += loss
total_loss /= (cnt + 1)
deco_print("Validation loss: {:.4f}".format(total_loss), offset=4)
dict_to_log = self._model.maybe_evaluate(
inputs_per_batch,
After Change
self._model, run_context.session, compute_loss=True,
)
if not self._model.on_horovod or self._model._hvd.rank() == 0:
deco_print("Validation loss: {:.4f}".format(total_loss), offset=4)
dict_to_log = self._model.maybe_evaluate(
inputs_per_batch,
outputs_per_batch,
)
dict_to_log["eval_loss"] = total_loss
// saving the best validation model
if total_loss < self._best_eval_loss:
self._best_eval_loss = total_loss
self._eval_saver.save(
run_context.session,
os.path.join(self._model.params["logdir"], "best_models",
"val_loss={:.4f}-step".format(total_loss)),
global_step=step + 1,
)
// optionally logging to tensorboard any values
// returned from maybe_print_logs
if dict_to_log:
log_summaries_from_dict(
dict_to_log,
self._model.params["logdir"],
step,
)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 3578019be301ae9d8e9b7518daa5fb113d00d2db
Time: 2018-05-07
Author: igor.a.gitman@gmail.com
File Name: open_seq2seq/utils/hooks.py
Class Name: RunEvaluationHook
Method Name: after_run
Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 80373cedf76f85b47de78080712f508a46c5345c
Time: 2018-05-16
Author: okuchaiev@nvidia.com
File Name: open_seq2seq/models/text2text_test.py
Class Name: BasicText2TextWithAttentionTest
Method Name: test_train
Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 80373cedf76f85b47de78080712f508a46c5345c
Time: 2018-05-16
Author: okuchaiev@nvidia.com
File Name: open_seq2seq/models/text2text_test.py
Class Name: BasicText2TextWithAttentionTestOnHorovod
Method Name: test_train