Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'math' is not defined #69

Open
fangpengcheng95 opened this issue Mar 19, 2024 · 0 comments
Open

NameError: name 'math' is not defined #69

fangpengcheng95 opened this issue Mar 19, 2024 · 0 comments

Comments

@fangpengcheng95
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant