for i in range(200):
step += 1
if step % 20 == 0:
loss = random.random()
acc = random.random()
fitlog.add_loss(loss,name="Loss",step=step)
fitlog.add_metric({"dev":{"Acc":acc}}, step=step)
if acc>best_acc:
best_acc = acc
fitlog.add_best_metric({"dev":{"Acc":best_acc}})
when i run main.py,it‘s appear ’NameError: name 'math' is not defined‘, the main.py code as fllowing
import fitlog import random import argparse
parser = argparse.ArgumentParser() parser.add_argument('--demo', type=int, default=2)
fitlog.set_log_dir("logs/") # 设定日志存储的目录
args = parser.parse_args() fitlog.add_hyper(args) # 通过这种方式记录ArgumentParser的参数 fitlog.add_hyper_in_file(file) # 记录本文件中写死的超参数
hyper
rand_seed = 12345
hyper
random.seed(rand_seed) best_acc, best_step, step = 0, 0, 0
for i in range(200): step += 1 if step % 20 == 0: loss = random.random() acc = random.random() fitlog.add_loss(loss,name="Loss",step=step) fitlog.add_metric({"dev":{"Acc":acc}}, step=step) if acc>best_acc: best_acc = acc fitlog.add_best_metric({"dev":{"Acc":best_acc}})
当dev取得更好的performance就在test上evaluate一下
fitlog.finish() # finish the logging