def log_stats()

in blocksparse/quantize.py [0:0]


def log_stats(x, step, sat_val=65504.0, ftz_val=2.0**-24, freq=512, bfreq=512, logfile="", name=None):

    assert  freq == 0 or round(np.log2( freq)) == np.log2( freq)
    assert bfreq == 0 or round(np.log2(bfreq)) == np.log2(bfreq)

    # tack on timestamp if desired
    logfile = logfile % { "timestamp" : get_timestamp() }

    global log_init
    if logfile and logfile not in log_init:
        with open(logfile, 'w') as log:
            log.write("\t".join(stat_headers) + "\n")
        log_init.add(logfile)

    pow2 = int(np.log2(freq or bfreq))
    first_steps = [1 << p for p in range(pow2)]

    return log_stats_op(x, step,
        sat_val     = sat_val,
        ftz_val     = ftz_val,
        freq        = freq,
        bfreq       = bfreq,
        logfile     = logfile,
        first_steps = first_steps,
        name        = name or "log_stats")