Exemple #1
0
def report_func(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.report_every == -1 % opt.report_every:
        report_stats.output(epoch, batch + 1, num_batches, start_time)
        report_stats = table.Statistics(0, {})

    return report_stats
Exemple #2
0
def report_func(epoch: int, batch: int, num_batches: int, start_time: float, lr: float, report_stats: table.Statistics):
    """
    This is the user-defined batch-level traing progress report function.

    Args:
        epoch: current epoch count.
        batch: current batch count.
        num_batches: total number of batches.
        start_time: last report time.
        lr: current learning rate.
        report_stats: old Statistics instance.

    Returns:
        report_stats updated Statistics instance.
    """

    is_new_report = batch % args.batch_report_every == -1 % args.batch_report_every

    if is_new_report:
        report_stats.print_output(epoch, batch + 1, num_batches, start_time)
        report_stats = table.Statistics(loss=0, eval_result={})

    return report_stats, is_new_report, args.batch_report_every