Beispiel #1
0
def report_func(global_step, epoch, batch, num_batches, start_time, lr,
                report_stats):
    """
    This is the user-defined batch-level traing progress
    report function.
    Args:
        epoch(int): current epoch count.
        batch(int): current batch count.
        num_batches(int): total number of batches.
        start_time(float): last report time.
        lr(float): current learning rate.
        report_stats(Statistics): old Statistics instance.
    Returns:
        report_stats(Statistics): updated Statistics instance.
    """
    if batch % opt.steps_per_stats == -1 % opt.steps_per_stats:
        report_stats.print_out(epoch, batch + 1, num_batches, start_time)
        report_stats.log("progress",
                         summery_writer,
                         global_step,
                         learning_rate=lr,
                         ppl=report_stats.ppl(),
                         accuracy=report_stats.accuracy())
        report_stats = nmt.Statistics()

    return report_stats
Beispiel #2
0
def report_func(opt, global_step, epoch, batch, num_batches, start_time, lr,
                report_stats):
    if batch % opt.steps_per_stats == -1 % opt.steps_per_stats:
        report_stats.print_out(epoch, batch + 1, num_batches, start_time)
        report_stats = nmt.Statistics()

    return report_stats