压缩模型Compressor的train_optimizer参数是否需要设置?
Created by: yanyq1990
如题,在对模型进行压缩时,train_optimizer参数是否需要设置,文档提到,train program如果带反向operators和优化更新相关的operators, train_optimizer需要设置为None,不是很明白这话的意思,是指的train program设置了优化器optimizer吗?参考示例代码的,哪怕是设置了optimizer,最后Compressor的参数train_optimizer也没有设置为None,并且如果在使用中设置为None,训练过程中的loss不下降,而设置train_optimizer不为None,会报错如下:
Traceback (most recent call last):
File "pruning.py", line 119, in <module>
compress()
File "pruning.py", line 113, in compress
com_pass.run()
File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/contrib/slim/core/compressor.py", line 517, in run
context.train_optimizer, context.place, context.scope)
File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/contrib/slim/graph/graph_wrapper.py", line 417, in get_optimize_graph
optimizer.minimize(target, no_grad_set=no_grad_var_names)
File "</usr/local/lib/python2.7/dist-packages/decorator.pyc:decorator-gen-20>", line 2, in minimize
File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/wrapped_decorator.py", line 25, in __impl__
return wrapped_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/dygraph/base.py", line 87, in __impl__
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/optimizer.py", line 609, in minimize
no_grad_set=no_grad_set)
File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/optimizer.py", line 494, in backward
no_grad_set, callbacks)
File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/backward.py", line 706, in append_backward
_append_backward_vars_(root_block, fwd_op_num, grad_to_var, grad_info_map)
File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/backward.py", line 518, in _append_backward_vars_
op_desc.infer_shape(block.desc)
IndexError: _Map_base::at