PaddleSlim剪切报错 pruner.py 维度上的index报错
Created by: universea
配置文件如下 version: 1.0 pruners: pruner_1: class: 'StructurePruner' pruning_axis: '': 0 criterions: '': 'l1_norm' strategies: uniform_pruning_strategy: class: 'UniformPruneStrategy' pruner: 'pruner_1' start_epoch: 0 target_ratio: 0.5 pruned_params: 'conv.*w_0' metric_name: 'map' quantization_strategy: class: 'QuantizationStrategy' start_epoch: 10 end_epoch: 14 float_model_save_path: './output/float' mobile_model_save_path: './output/mobile' int8_model_save_path: './output/int8' weight_bits: 8 activation_bits: 8 weight_quantize_type: 'abs_max' activation_quantize_type: 'abs_max' compressor: epoch: 15 #init_model: './checkpoints/0' # Please enable this option for loading checkpoint. checkpoint_path: './checkpoint/' strategies: - uniform_pruning_strategy - quantization_strategy 报错如下 2019-08-01 20:44:03,772-INFO: _get_best_ratios 2019-08-01 20:44:03,772-INFO: _get_best_ratios Traceback (most recent call last): File "/opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/contrib/slim/core/compressor.py", line 534, in run strategy.on_epoch_begin(context) File "/opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/contrib/slim/prune/prune_strategy.py", line 640, in on_epoch_begin params, ratios = self._get_best_ratios(context) File "/opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/contrib/slim/prune/prune_strategy.py", line 618, in _get_best_ratios param_shape_backup=param_shape_backup) File "/opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/contrib/slim/prune/prune_strategy.py", line 477, in _prune_parameters param_shape_backup=param_shape_backup) File "/opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/contrib/slim/prune/prune_strategy.py", line 322, in _forward_pruning_ralated_params param_shape_backup=param_shape_backup) File "/opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/contrib/slim/prune/prune_strategy.py", line 159, in _prune_parameter_by_idx np.array(param_t), pruned_idx, pruned_axis, lazy=lazy) File "/opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/contrib/slim/prune/pruner.py", line 95, in prune_tensor mask[pruned_idx] = True IndexError: index 513 is out of bounds for axis 0 with size 512 2019-08-01 20:44:03,957-ERROR: None 2019-08-01 20:44:03,957-ERROR: None 2019-08-01 20:44:03,979-WARNING: You can try our memory optimize feature to save your memory usage: # create a build_strategy variable to set memory optimize option build_strategy = compiler.BuildStrategy() build_strategy.enable_inplace = True build_strategy.memory_optimize = True
# pass the build_strategy to with_data_parallel API
compiled_prog = compiler.CompiledProgram(main).with_data_parallel(
loss_name=loss.name, build_strategy=build_strategy)
!!! Memory optimize is our experimental feature !!!
some variables may be removed/reused internal to save memory usage,
in order to fetch the right value of the fetch_list, please set the
persistable property to true for each variable in fetch_list
# Sample
conv1 = fluid.layers.conv2d(data, 4, 5, 1, act=None)
# if you need to fetch conv1, then:
conv1.persistable = True