提交 57932ed5 编写于 作者: X Xin Pan

fix model to use different names for train and test so that var name don't conflict

上级 c3e77c50
...@@ -92,24 +92,25 @@ def build_program(main_prog, startup_prog, train_params, is_train): ...@@ -92,24 +92,25 @@ def build_program(main_prog, startup_prog, train_params, is_train):
image, gt_box, gt_label, difficult = fluid.layers.read_file(py_reader) image, gt_box, gt_label, difficult = fluid.layers.read_file(py_reader)
locs, confs, box, box_var = mobile_net(class_num, image, image_shape) locs, confs, box, box_var = mobile_net(class_num, image, image_shape)
if is_train: if is_train:
loss = fluid.layers.ssd_loss(locs, confs, gt_box, gt_label, box, with fluid.unique_name.guard("train"):
box_var) loss = fluid.layers.ssd_loss(locs, confs, gt_box, gt_label, box,
loss = fluid.layers.reduce_sum(loss) box_var)
optimizer = optimizer_setting(train_params) loss = fluid.layers.reduce_sum(loss)
optimizer.minimize(loss) optimizer = optimizer_setting(train_params)
optimizer.minimize(loss)
else: else:
with fluid.unique_name.guard("inference"):
nmsed_out = fluid.layers.detection_output( nmsed_out = fluid.layers.detection_output(
locs, confs, box, box_var, nms_threshold=0.45) locs, confs, box, box_var, nms_threshold=0.45)
loss = fluid.evaluator.DetectionMAP( loss = fluid.evaluator.DetectionMAP(
nmsed_out, nmsed_out,
gt_label, gt_label,
gt_box, gt_box,
difficult, difficult,
class_num, class_num,
overlap_threshold=0.5, overlap_threshold=0.5,
evaluate_difficult=False, evaluate_difficult=False,
ap_version=ap_version) ap_version=ap_version)
return py_reader, loss return py_reader, loss
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册