提交 3ec7d48c 编写于 作者: B baiyfbupt

code refine

上级 02ae18ab
...@@ -326,6 +326,10 @@ def train_eval_det_run(config, ...@@ -326,6 +326,10 @@ def train_eval_det_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
strs = 'Test iter: {}, metrics:{}, best_hmean:{:.6f}, best_epoch:{}, best_batch_id:{}'.format( strs = 'Test iter: {}, metrics:{}, best_hmean:{:.6f}, best_epoch:{}, best_batch_id:{}'.format(
train_batch_id, metrics, best_eval_hmean, best_epoch, train_batch_id, metrics, best_eval_hmean, best_epoch,
best_batch_id) best_batch_id)
...@@ -345,6 +349,10 @@ def train_eval_det_run(config, ...@@ -345,6 +349,10 @@ def train_eval_det_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
if epoch > 0 and epoch % save_epoch_step == 0: if epoch > 0 and epoch % save_epoch_step == 0:
save_path = save_model_dir + "/iter_epoch_%d" % (epoch) save_path = save_model_dir + "/iter_epoch_%d" % (epoch)
if is_slim is None: if is_slim is None:
...@@ -356,6 +364,10 @@ def train_eval_det_run(config, ...@@ -356,6 +364,10 @@ def train_eval_det_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
return return
...@@ -454,6 +466,10 @@ def train_eval_rec_run(config, ...@@ -454,6 +466,10 @@ def train_eval_rec_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
strs = 'Test iter: {}, acc:{:.6f}, best_acc:{:.6f}, best_epoch:{}, best_batch_id:{}, eval_sample_num:{}'.format( strs = 'Test iter: {}, acc:{:.6f}, best_acc:{:.6f}, best_epoch:{}, best_batch_id:{}, eval_sample_num:{}'.format(
train_batch_id, eval_acc, best_eval_acc, best_epoch, train_batch_id, eval_acc, best_eval_acc, best_epoch,
best_batch_id, eval_sample_num) best_batch_id, eval_sample_num)
...@@ -473,6 +489,10 @@ def train_eval_rec_run(config, ...@@ -473,6 +489,10 @@ def train_eval_rec_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
if epoch > 0 and epoch % save_epoch_step == 0: if epoch > 0 and epoch % save_epoch_step == 0:
save_path = save_model_dir + "/iter_epoch_%d" % (epoch) save_path = save_model_dir + "/iter_epoch_%d" % (epoch)
if is_slim is None: if is_slim is None:
...@@ -484,6 +504,10 @@ def train_eval_rec_run(config, ...@@ -484,6 +504,10 @@ def train_eval_rec_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
return return
...@@ -565,6 +589,10 @@ def train_eval_cls_run(config, ...@@ -565,6 +589,10 @@ def train_eval_cls_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
strs = 'Test iter: {}, acc:{:.6f}, best_acc:{:.6f}, best_epoch:{}, best_batch_id:{}, eval_sample_num:{}'.format( strs = 'Test iter: {}, acc:{:.6f}, best_acc:{:.6f}, best_epoch:{}, best_batch_id:{}, eval_sample_num:{}'.format(
train_batch_id, eval_acc, best_eval_acc, best_epoch, train_batch_id, eval_acc, best_eval_acc, best_epoch,
best_batch_id, eval_sample_num) best_batch_id, eval_sample_num)
...@@ -584,6 +612,10 @@ def train_eval_cls_run(config, ...@@ -584,6 +612,10 @@ def train_eval_cls_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
if epoch > 0 and epoch % save_epoch_step == 0: if epoch > 0 and epoch % save_epoch_step == 0:
save_path = save_model_dir + "/iter_epoch_%d" % (epoch) save_path = save_model_dir + "/iter_epoch_%d" % (epoch)
if is_slim is None: if is_slim is None:
...@@ -595,6 +627,10 @@ def train_eval_cls_run(config, ...@@ -595,6 +627,10 @@ def train_eval_cls_run(config,
save_path) save_path)
elif is_slim == "quant": elif is_slim == "quant":
save_model(eval_info_dict['program'], save_path) save_model(eval_info_dict['program'], save_path)
else:
raise ValueError(
"Only quant and prune are supported currently. But received {}".
format(is_slim))
return return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册