diff --git a/demo/auto-compression/README.md b/demo/auto-compression/README.md index b61d67d666e1849d7ad039022fa7f7884f97f760..e69329ea73619ef7c477e3291791d72308c28be1 100644 --- a/demo/auto-compression/README.md +++ b/demo/auto-compression/README.md @@ -88,7 +88,7 @@ python demo_imagenet.py \ --model_dir='infermodel_mobilenetv2' \ --model_filename='inference.pdmodel' \ --params_filename='./inference.pdiparams' \ - --save_dir='./save_qat_mbv2/' \ + --save_dir='./save_ptq_mbv2/' \ --devices='gpu' \ --batch_size=64 \ --data_dir='../data/ILSVRC2012/' \ @@ -118,7 +118,7 @@ python demo_imagenet.py \ --model_dir='infermodel_mobilenetv2' \ --model_filename='inference.pdmodel' \ --params_filename='./inference.pdiparams' \ - --save_dir='./save_qat_mbv2/' \ + --save_dir='./save_asp_mbv2/' \ --devices='gpu' \ --batch_size=64 \ --data_dir='../data/ILSVRC2012/' \ diff --git a/demo/auto-compression/demo_glue.py b/demo/auto-compression/demo_glue.py index 569bd7cc076bfd7ef53117f10a78a3c0133b3979..a2b0cfded593b77debb0373105b0a199a11fb31e 100644 --- a/demo/auto-compression/demo_glue.py +++ b/demo/auto-compression/demo_glue.py @@ -189,7 +189,7 @@ if __name__ == '__main__': strategy_config=compress_config, train_config=train_config, train_dataloader=train_dataloader, - eval_callback=eval_function, + eval_callback=eval_function if 'HyperParameterOptimization' not in compress_config else eval_dataloader, devices=args.devices) ac.compress() diff --git a/demo/auto-compression/demo_imagenet.py b/demo/auto-compression/demo_imagenet.py index 62394810dd320def4fc57a154465a8f6950593da..04543228f6a020fa48d9d68658e6f9f3ac19e6ef 100644 --- a/demo/auto-compression/demo_imagenet.py +++ b/demo/auto-compression/demo_imagenet.py @@ -37,10 +37,12 @@ def reader_wrapper(reader): return gen +def eval_reader(data_dir, batch_size): + val_reader = paddle.batch(reader.val(data_dir=data_dir), batch_size=batch_size) + return val_reader def eval_function(exe, compiled_test_program, test_feed_names, test_fetch_list): - - val_reader = paddle.batch(reader.val(data_dir=data_dir), batch_size=1) + val_reader = eval_reader(data_dir, batch_size=1) image = paddle.static.data( name='x', shape=[None, 3, 224, 224], dtype='float32') label = paddle.static.data(name='label', shape=[None, 1], dtype='int64') @@ -102,7 +104,7 @@ if __name__ == '__main__': strategy_config=compress_config, train_config=train_config, train_dataloader=train_dataloader, - eval_callback=eval_function if 'HyperParameterOptimization' not in compress_config else None, + eval_callback=eval_function if 'HyperParameterOptimization' not in compress_config else reader_wrapper(eval_reader(data_dir, 64)), devices=args.devices) ac.compress()