importpaddleslimimportpaddleimportnumpyasnpfrompaddleslim.dygraphimportFPGMFilterPrunerdefprune_model(model,input_shape,prune_ratio=0.1):flops=paddle.flops(model,input_shape)pruner=FPGMFilterPruner(model,input_shape)params_sensitive={}forparaminmodel.parameters():if'transpose'notinparam.nameand'linear'notinparam.name:# set prune ratio as 10%. The larger the value, the more convolution weights will be croppedparams_sensitive[param.name]=prune_ratioplan=pruner.prune_vars(params_sensitive,[0])flops=paddle.flops(model,input_shape)returnmodel