diff --git a/fluid/image_classification/_ce.py b/fluid/image_classification/_ce.py index 0030bed1759390f2dad0843d10488f91b04f42b7..5eb8e24534bf266241cc071e9291719c1c17b1d8 100644 --- a/fluid/image_classification/_ce.py +++ b/fluid/image_classification/_ce.py @@ -7,14 +7,14 @@ from kpi import CostKpi, DurationKpi, AccKpi #### NOTE kpi.py should shared in models in some way!!!! -train_acc_top1_kpi = AccKpi('train_acc_top1', 0.05, 0, desc='TOP1 ACC') +train_acc_top1_kpi = AccKpi('train_acc_top1', 0.005, 0, desc='TOP1 ACC') train_acc_top5_kpi = AccKpi( - 'train_acc_top5', 0.05, 0, actived=False, desc='TOP5 ACC') + 'train_acc_top5', 0.005, 0, actived=True, desc='TOP5 ACC') train_cost_kpi = CostKpi('train_cost', 0.5, 0, actived=True, desc='train cost') -test_acc_top1_kpi = AccKpi('test_acc_top1', 0.05, 0, desc='TOP1 ACC') +test_acc_top1_kpi = AccKpi('test_acc_top1', 0.005, 0, desc='TOP1 ACC') test_acc_top5_kpi = AccKpi( - 'test_acc_top5', 0.05, 0, actived=False, desc='TOP5 ACC') -test_cost_kpi = CostKpi('test_cost', 1.0, 0, actived=True, desc='train cost') + 'test_acc_top5', 0.005, 0, actived=True, desc='TOP5 ACC') +test_cost_kpi = CostKpi('test_cost', 0.005, 0, actived=True, desc='train cost') train_speed_kpi = AccKpi( 'train_speed', 0.5, @@ -23,17 +23,17 @@ train_speed_kpi = AccKpi( unit_repr='seconds/image', desc='train speed in one GPU card') train_acc_top1_card4_kpi = AccKpi( - 'train_acc_top1_card4', 0.05, 0, desc='TOP1 ACC') + 'train_acc_top1_card4', 0.005, 0, desc='TOP1 ACC') train_acc_top5_card4_kpi = AccKpi( - 'train_acc_top5_card4', 0.05, 0, actived=False, desc='TOP5 ACC') + 'train_acc_top5_card4', 0.005, 0, actived=True, desc='TOP5 ACC') train_cost_card4_kpi = CostKpi( - 'train_cost_kpi', 0.3, 0, actived=True, desc='train cost') + 'train_cost_kpi', 0.005, 0, actived=True, desc='train cost') test_acc_top1_card4_kpi = AccKpi( - 'test_acc_top1_card4', 0.05, 0, desc='TOP1 ACC') + 'test_acc_top1_card4', 0.005, 0, desc='TOP1 ACC') test_acc_top5_card4_kpi = AccKpi( - 'test_acc_top5_card4', 0.05, 0, actived=False, desc='TOP5 ACC') + 'test_acc_top5_card4', 0.005, 0, actived=True, desc='TOP5 ACC') test_cost_card4_kpi = CostKpi( - 'test_cost_card4', 1.0, 0, actived=True, desc='train cost') + 'test_cost_card4', 0.005, 0, actived=True, desc='train cost') train_speed_card4_kpi = AccKpi( 'train_speed_card4', 0.5, diff --git a/fluid/image_classification/train.py b/fluid/image_classification/train.py index aed5802c8e75bb2a636b39f1627cd7333e9109cc..48bf53297db35ac7cb5fc4cf0f9fb8ad6c1bf1e8 100644 --- a/fluid/image_classification/train.py +++ b/fluid/image_classification/train.py @@ -104,6 +104,8 @@ def train(args): if args.enable_ce: assert model_name == "SE_ResNeXt50_32x4d" + fluid.default_startup_program().random_seed = 1000 + model.params["dropout_seed"] = 100 if model_name is "GoogleNet": out0, out1, out2 = model.net(input=image, class_dim=class_dim) @@ -134,8 +136,6 @@ def train(args): params["num_epochs"] = args.num_epochs params["learning_strategy"]["batch_size"] = args.batch_size params["learning_strategy"]["name"] = args.lr_strategy - if args.enable_ce: - params["dropout_seed"] = 10 # initialize optimizer optimizer = optimizer_setting(params) @@ -144,9 +144,6 @@ def train(args): if with_memory_optimization: fluid.memory_optimize(fluid.default_main_program()) - if args.enable_ce: - fluid.default_startup_program().random_seed = 1000 - place = fluid.CUDAPlace(0) if args.use_gpu else fluid.CPUPlace() exe = fluid.Executor(place) exe.run(fluid.default_startup_program()) @@ -172,6 +169,7 @@ def train(args): # but it is time consuming. For faster speed, need another dataset. import random random.seed(0) + np.random.seed(0) train_reader = paddle.batch( flowers.train(use_xmap=False), batch_size=train_batch_size) test_reader = paddle.batch(