compare_accuracy

paddle.amp.debugging. compare_accuracy ( dump_path, another_dump_path, output_filename, loss_scale=1, dump_all_tensors=False ) [source]

This is a precision comparison tool that can be used to compare log data of float16 and float32.

Parameters
  • dump_path (str) – The path of the running log, such as the log for execution using the float32 data type.

  • another_dump_path (str) – the path of another running log ,such as the log for execution using the float16 data type.

  • output_filename (str) – the excel file nmae of compare output.

  • loss_scale (float, optional) – the loss_scale during the training phase. Default is 1.

  • dump_all_tensors (bool, optional) – dump all tensor, It is currently not support. Default is False.

Examples

import paddle
from paddle.fluid import core
try:
    import xlsxwriter as xlw
except ImportError:
    import subprocess

    subprocess.check_call(
        ['python', '-m', 'pip', 'install', 'xlsxwriter==3.0.9']
    )
    import xlsxwriter as xlw

if core.is_compiled_with_cuda():
    paddle.set_flags(
        {"FLAGS_check_nan_inf": 1, "FLAGS_check_nan_inf_level": 3}
    )
    path = "workerlog_log_dir"
    paddle.fluid.core.set_nan_inf_debug_path(path)
    x = paddle.to_tensor(
        [2, 3, 4, 0], dtype="float32"
    )
    y = paddle.to_tensor(
        [1, 5, 2, 0], dtype="float32"
    )
    z1 = x + y
    out_excel = "compary_accuracy_out_excel.csv"
    paddle.amp.debugging.compare_accuracy(
        path, path, out_excel, loss_scale=1, dump_all_tensors=False
    )