Skip to content

Commit

Permalink
add ce for slim (PaddlePaddle#4119)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmglove authored and wanghaoshuang committed Dec 25, 2019
1 parent 68d1771 commit 8931657
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions PaddleSlim/classification/distillation/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@
add_arg('teacher_model', str, None, "Set the teacher network to use.")
add_arg('teacher_pretrained_model', str, None, "Whether to use pretrained model.")
add_arg('compress_config', str, None, "The config file for compression with yaml format.")
add_arg('enable_ce', bool, False, "If set, run the task with continuous evaluation logs.")

# yapf: enable

model_list = [m for m in dir(models) if "__" not in m]


def compress(args):
# add ce
if args.enable_ce:
SEED = 1
fluid.default_main_program().random_seed = SEED
fluid.default_startup_program().random_seed = SEED

image_shape = [int(m) for m in args.image_shape.split(",")]

assert args.model in model_list, "{} is not in lists: {}".format(args.model,
Expand Down
7 changes: 7 additions & 0 deletions PaddleSlim/classification/pruning/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
add_arg('total_images', int, 1281167, "The number of total training images.")
parser.add_argument('--step_epochs', nargs='+', type=int, default=[30, 60, 90], help="piecewise decay step")
add_arg('config_file', str, None, "The config file for compression with yaml format.")
add_arg('enable_ce', bool, False, "If set, run the task with continuous evaluation logs.")
# yapf: enable


Expand Down Expand Up @@ -68,6 +69,12 @@ def create_optimizer(args):
return cosine_decay(args)

def compress(args):
# add ce
if args.enable_ce:
SEED = 1
fluid.default_main_program().random_seed = SEED
fluid.default_startup_program().random_seed = SEED

class_dim=1000
image_shape="3,224,224"
image_shape = [int(m) for m in image_shape.split(",")]
Expand Down
7 changes: 7 additions & 0 deletions PaddleSlim/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@
add_arg('teacher_pretrained_model', str, None, "Whether to use pretrained model.")
add_arg('compress_config', str, None, "The config file for compression with yaml format.")
add_arg('quant_only', bool, False, "Only do quantization-aware training.")
add_arg('enable_ce', bool, False, "If set, run the task with continuous evaluation logs.")
# yapf: enable

model_list = [m for m in dir(models) if "__" not in m]


def compress(args):
# add ce
if args.enable_ce:
SEED = 1
fluid.default_main_program().random_seed = SEED
fluid.default_startup_program().random_seed = SEED

image_shape = [int(m) for m in args.image_shape.split(",")]

assert args.model in model_list, "{} is not in lists: {}".format(args.model,
Expand Down

0 comments on commit 8931657

Please sign in to comment.