fastnlp / fitlog

fitlog是一款在深度学习训练中用于辅助用户记录日志和管理代码的工具
https://gitee.com/fastnlp/fitlog
Apache License 2.0
1.48k stars 129 forks source link

NameError: name 'math' is not defined #69

Open fangpengcheng95 opened 8 months ago

fangpengcheng95 commented 8 months ago

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一下

        test_acc = random.random()
        fitlog.add_best_metric({"test":{"Acc":test_acc}})

fitlog.finish() # finish the logging

dawnlh commented 2 months ago

用pip安装最新版本的,或者定位到报错文件 加上 import math 就可以了