def test(db, system_config, model, args): split = args.split testiter = args.testiter debug = args.debug suffix = args.suffix result_dir = system_config.result_dir result_dir = os.path.join(result_dir, str(testiter), split) if suffix is not None: result_dir = os.path.join(result_dir, suffix) make_dirs([result_dir]) test_iter = system_config.max_iter if testiter is None else testiter print("loading parameters at iteration: {}".format(test_iter)) print("building neural network...") nnet = NetworkFactory(system_config, model, test=True) print("loading parameters...") nnet.load_params(test_iter) nnet.cuda() nnet.eval_mode() test_func(system_config, db, nnet, result_dir, debug=debug)
def test(db, system_config, model, args): split = args.split testiter = args.testiter debug = args.debug suffix = args.suffix # 输出的文件夹result_dir+testiter+split result_dir = system_config.result_dir result_dir = os.path.join(result_dir, str(testiter), split) # 后缀的添加 if suffix is not None: result_dir = os.path.join(result_dir, suffix) # 创建文件夹 make_dirs([result_dir]) # 赋值test_iter 如果没有传入就用预设值 test_iter = system_config.max_iter if testiter is None else testiter print("loading parameters at iteration: {}".format(test_iter)) # 构建神经网络 print("building neural network...") nnet = NetworkFactory(system_config, model) print("loading parameters...") nnet.load_params(test_iter) nnet.cuda() nnet.eval_mode() test_func(system_config, db, nnet, result_dir, debug=debug)
def test(db, system_config, model, args): print("\033[0;35;46m" + "{}".format(" ") * 100 + "\033[0m") print("\033[0;33m " + "现在位置:{}/{}/.{}".format(os.getcwd(), os.path.basename(__file__), sys._getframe().f_code.co_name) + "\033[0m") split = args.split testiter = args.testiter debug = args.debug suffix = args.suffix print("\033[0;36m " + "{}".format("测试用的配置参数") + "\033[0m") print("\033[1;36m " + "split: {}, testiter:{}, debug:{}, suffix:{}".format( split, testiter, debug, suffix) + "\033[0m") # 输出的文件夹result_dir+testiter+split result_dir = system_config.result_dir result_dir = os.path.join(result_dir, str(testiter), split) # 后缀的添加 if suffix is not None: result_dir = os.path.join(result_dir, suffix) # 创建文件夹 make_dirs([result_dir]) print("\033[1;36m " + "result_dir:{}".format(result_dir) + "\033[0m") # 赋值test_iter 如果没有传入就用预设值 test_iter = system_config.max_iter if testiter is None else testiter print("\033[1;36m " + "loading parameters at iteration(在迭代次数为test_iter的缓存文件中加载参数): " + "\033[0m" + "{}".format(test_iter)) # 构建神经网络 print("\033[0;36m " + "{}".format("building neural network(创建神经网络)...") + "\033[0m") nnet = NetworkFactory(system_config, model) print("\033[0;36m " + "{}".format("loading parameters(加载参数)...") + "\033[0m") nnet.load_params(test_iter) nnet.cuda() nnet.eval_mode() test_func(system_config, db, nnet, result_dir, debug=debug)
def test(db, system_config, nnet, val_iter, split, debug=False, suffix=None): split = split testiter = val_iter debug = debug suffix = suffix result_dir = system_config.result_dir result_dir = os.path.join(result_dir, str(testiter), split) if suffix is not None: result_dir = os.path.join(result_dir, suffix) make_dirs([result_dir]) a, b, detect_average_time = test_func(system_config, db, nnet, result_dir, debug=debug) return a, b, detect_average_time