cls_task.finetune_and_eval() 报错
Created by: cchan19
在百度AI STUDIO运行文本分类任务示例:https://github.com/PaddlePaddle/PaddleHub/tree/release/v1.1.0/demo/text-classification
cls_task.finetune_and_eval() 报错: ---------------------------------------------------------------------------EnforceNotMet Traceback (most recent call last) in ----> 1 cls_task.finetune_and_eval() /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddlehub/finetune/task.py in finetune_and_eval(self) 504 505 def finetune_and_eval(self): --> 506 return self.finetune(do_eval=True) 507 508 def finetune(self, do_eval=False): /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddlehub/finetune/task.py in finetune(self, do_eval) 509 # Start to finetune 510 with self.phase_guard(phase="train"): --> 511 self.init_if_necessary() 512 self._finetune_start_event() 513 run_states = [] /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddlehub/finetune/task.py in init_if_necessary(self) 166 if not self.is_checkpoint_loaded: 167 self.is_checkpoint_loaded = True --> 168 if not self.load_checkpoint(): 169 self.exe.run(self._base_startup_program) 170 /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddlehub/finetune/task.py in load_checkpoint(self) 487 self.config.checkpoint_dir, 488 self.exe, --> 489 main_program=self.main_program) 490 491 return is_load_successful /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddlehub/finetune/task.py in main_program(self) 331 def main_program(self): 332 if not self.env.is_inititalized: --> 333 self._build_env() 334 return self.env.main_program 335 /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddlehub/finetune/task.py in _build_env(self) 244 with fluid.unique_name.guard(self.env.UNG): 245 self.config.strategy.execute( --> 246 self.loss, self._base_data_reader, self.config) 247 248 if self.is_train_phase: /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddlehub/finetune/strategy.py in execute(self, loss, data_reader, config) 132 scheduled_lr = adam_weight_decay_optimization( 133 loss, warmup_steps, max_train_steps, self.learning_rate, --> 134 main_program, self.weight_decay, self.lr_scheduler) 135 136 return scheduled_lr /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddlehub/finetune/optimization.py in adam_weight_decay_optimization(loss, warmup_steps, num_train_steps, learning_rate, main_program, weight_decay, scheduler) 77 param_list[param.name].stop_gradient = True 78 ---> 79 _, param_grads = optimizer.minimize(loss) 80 81 if weight_decay > 0: </opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/decorator.py:decorator-gen-144> in minimize(self, loss, startup_program, parameter_list, no_grad_set, grad_clip) /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/wrapped_decorator.py in impl(func, args, kwargs) 23 def impl(func, args, *kwargs): 24 wrapped_func = decorator_func(func) ---> 25 return wrapped_func(args, *kwargs) 26 27 return impl /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/dygraph/base.py in impl(args, **kwargs) 86 def impl(args, kwargs): 87 with switch_tracer_mode_guard(is_train=False): ---> 88 return func(args, kwargs) 89 90 return impl /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/optimizer.py in minimize(self, loss, startup_program, parameter_list, no_grad_set, grad_clip) 591 startup_program=startup_program, 592 parameter_list=parameter_list, --> 593 no_grad_set=no_grad_set) 594 595 if grad_clip is not None and framework.in_dygraph_mode(): /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/optimizer.py in backward(self, loss, startup_program, parameter_list, no_grad_set, callbacks) 491 with program_guard(program, startup_program): 492 params_grads = append_backward(loss, parameter_list, --> 493 no_grad_set, callbacks) 494 # Note: since we can't use all_reduce_op now, 495 # dgc_op should be the last op of one grad. /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/backward.py in append_backward(loss, parameter_list, no_grad_set, callbacks) 568 grad_to_var, 569 callbacks, --> 570 input_grad_names_set=input_grad_names_set) 571 572 # Because calc_gradient may be called multiple times, /opt/conda/envs/python35-paddle120-env/lib/python3.5/site-packages/paddle/fluid/backward.py in append_backward_ops(block, ops, target_block, no_grad_dict, grad_to_var, callbacks, input_grad_names_set) 308 # Getting op's corresponding grad_op 309 grad_op_desc, op_grad_to_var = core.get_grad_op_desc( --> 310 op.desc, cpt.to_text(no_grad_dict[block.idx]), grad_sub_block_list) 311 312 # If input_grad_names_set is not None, extend grad_op_descs only when EnforceNotMet: Input ShapeTensor cannot be found in Op reshape2 at [/paddle/paddle/fluid/framework/op_desc.cc:306] PaddlePaddle Call Stacks: 0 0x7f991b9132e0p void paddle::platform::EnforceNotMet::Init<char const>(char const, char const, int) + 352 1 0x7f991b913659p paddle::platform::EnforceNotMet::EnforceNotMet(std::__exception_ptr::exception_ptr, char const, int) + 137 2 0x7f991ba8423fp paddle::framework::OpDesc::Input(std::string const&) const + 207 3 0x7f991bf537fcp paddle::framework::details::OpInfoFiller<paddle::operators::Reshape2GradMaker, (paddle::framework::details::OpInfoFillType)2>::operator()(char const, paddle::framework::OpInfo) const::{lambda(paddle::framework::OpDesc const&, std::unordered_set<std::string, std::hashstd::string, std::equal_tostd::string, std::allocatorstd::string > const&, std::unordered_map<std::string, std::string, std::hashstd::string, std::equal_tostd::string, std::allocator<std::pair<std::string const, std::string> > >, std::vector<paddle::framework::BlockDesc, std::allocatorpaddle::framework::BlockDesc* > const&)#1 (closed)}::operator()(paddle::framework::OpDesc const&, std::unordered_set<std::string, std::hashstd::string, std::equal_tostd::string, std::allocatorstd::string > const&, std::unordered_map<std::string, std::string, std::hashstd::string, std::equal_tostd::string, std::allocator<std::pair<std::string const, std::string> > >, std::vector<paddle::framework::BlockDesc, std::allocatorpaddle::framework::BlockDesc* > const&) const + 540 4 0x7f991bf53d74p std::_Function_handler<std::vector<std::unique_ptr<paddle::framework::OpDesc, std::default_deletepaddle::framework::OpDesc >, std::allocator<std::unique_ptr<paddle::framework::OpDesc, std::default_deletepaddle::framework::OpDesc > > > (paddle::framework::OpDesc const&, std::unordered_set<std::string, std::hashstd::string, std::equal_tostd::string, std::allocatorstd::string > const&, std::unordered_map<std::string, std::string, std::hashstd::string, std::equal_tostd::string, std::allocator<std::pair<std::string const, std::string> > >, std::vector<paddle::framework::BlockDesc, std::allocatorpaddle::framework::BlockDesc* > const&), paddle::framework::details::OpInfoFiller<paddle::operators::Reshape2GradMaker, (paddle::framework::details::OpInfoFillType)2>::operator()(char const, paddle::framework::OpInfo) const::{lambda(paddle::framework::OpDesc const&, std::unordered_set<std::string, std::hashstd::string, std::equal_tostd::string, std::allocatorstd::string > const&, std::unordered_map<std::string, std::string, std::hashstd::string, std::equal_tostd::string, std::allocator<std::pair<std::string const, std::string> > >, std::vector<paddle::framework::BlockDesc, std::allocatorpaddle::framework::BlockDesc* > const&)#1 (closed)}>::_M_invoke(std::_Any_data const&, paddle::framework::OpDesc const&, std::unordered_set<std::string, std::hashstd::string, std::equal_tostd::string, std::allocatorstd::string > const&, std::unordered_map<std::string, std::string, std::hashstd::string, std::equal_tostd::string, std::allocator<std::pair<std::string const, std::string> > >, std::vector<paddle::framework::BlockDesc, std::allocatorpaddle::framework::BlockDesc* > const&) + 20 5 0x7f991b90c24ap 6 0x7f991b945ca6p 7 0x7f999ff31199p PyCFunction_Call + 233 8 0x7f999ffcbdbep PyEval_EvalFrameEx + 31950 9 0x7f999ffce4b6p 10 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 11 0x7f999ffce4b6p 12 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 13 0x7f999ffce4b6p 14 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 15 0x7f999ffce4b6p 16 0x7f999ffce5a8p PyEval_EvalCodeEx + 72 17 0x7f999ff0dc33p 18 0x7f999fedc33ap PyObject_Call + 106 19 0x7f999ffc66eep PyEval_EvalFrameEx + 9726 20 0x7f999ffce4b6p 21 0x7f999ffce5a8p PyEval_EvalCodeEx + 72 22 0x7f999ff0dc33p 23 0x7f999fedc33ap PyObject_Call + 106 24 0x7f999ffc66eep PyEval_EvalFrameEx + 9726 25 0x7f999ffce4b6p 26 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 27 0x7f999ffce4b6p 28 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 29 0x7f999ffce4b6p 30 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 31 0x7f999ffcc1d0p PyEval_EvalFrameEx + 32992 32 0x7f999ffce4b6p 33 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 34 0x7f999ffce4b6p 35 0x7f999ffce5a8p PyEval_EvalCodeEx + 72 36 0x7f999ff0db56p 37 0x7f999fedc33ap PyObject_Call + 106 38 0x7f999fefa172p 39 0x7f999ff3451cp _PyObject_GenericGetAttrWithDict + 124 40 0x7f999ffc8d2ap PyEval_EvalFrameEx + 19514 41 0x7f999ffcc1d0p PyEval_EvalFrameEx + 32992 42 0x7f999ffcc1d0p PyEval_EvalFrameEx + 32992 43 0x7f999ffce4b6p 44 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 45 0x7f999ffcc1d0p PyEval_EvalFrameEx + 32992 46 0x7f999ffce4b6p 47 0x7f999ffce5a8p PyEval_EvalCodeEx + 72 48 0x7f999ffce5ebp PyEval_EvalCode + 59 49 0x7f999ffc1c5dp 50 0x7f999ff31179p PyCFunction_Call + 201 51 0x7f999ffcbdbep PyEval_EvalFrameEx + 31950 52 0x7f999ff05410p _PyGen_Send + 128 53 0x7f999ffca953p PyEval_EvalFrameEx + 26723 54 0x7f999ff05410p _PyGen_Send + 128 55 0x7f999ffca953p PyEval_EvalFrameEx + 26723 56 0x7f999ff05410p _PyGen_Send + 128 57 0x7f999ffcbd60p PyEval_EvalFrameEx + 31856 58 0x7f999ffcc1d0p PyEval_EvalFrameEx + 32992 59 0x7f999ffcc1d0p PyEval_EvalFrameEx + 32992 60 0x7f999ffce4b6p 61 0x7f999ffce5a8p PyEval_EvalCodeEx + 72 62 0x7f999ff0dc33p 63 0x7f999fedc33ap PyObject_Call + 106 64 0x7f999ffc66eep PyEval_EvalFrameEx + 9726 65 0x7f999ffce4b6p 66 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 67 0x7f999ff046bap 68 0x7f999ffbfaf6p 69 0x7f999ff31179p PyCFunction_Call + 201 70 0x7f999ffcbdbep PyEval_EvalFrameEx + 31950 71 0x7f999ffce4b6p 72 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 73 0x7f999ff046bap 74 0x7f999ffbfaf6p 75 0x7f999ff31179p PyCFunction_Call + 201 76 0x7f999ffcbdbep PyEval_EvalFrameEx + 31950 77 0x7f999ffce4b6p 78 0x7f999ffcb5b5p PyEval_EvalFrameEx + 29893 79 0x7f999ff046bap 80 0x7f999ffbfaf6p 81 0x7f999ff31179p PyCFunction_Call + 201 82 0x7f999ffcbdbep PyEval_EvalFrameEx + 31950 83 0x7f999ffce4b6p 84 0x7f999ffce5a8p PyEval_EvalCodeEx + 72 85 0x7f999ff0db56p 86 0x7f999fedc33ap PyObject_Call + 106 87 0x7f999ffc66eep PyEval_EvalFrameEx + 9726 88 0x7f999ff05410p _PyGen_Send + 128 89 0x7f999ffcbd60p PyEval_EvalFrameEx + 31856 90 0x7f999ffcc1d0p PyEval_EvalFrameEx + 32992 91 0x7f999ffce4b6p 92 0x7f999ffce5a8p PyEval_EvalCodeEx + 72 93 0x7f999ff0dc33p 94 0x7f999fedc33ap PyObject_Call + 106 95 0x7f999ffc66eep PyEval_EvalFrameEx + 9726 96 0x7f999ffce4b6p 97 0x7f999ffce5a8p PyEval_EvalCodeEx + 72 98 0x7f999ff0db56p 99 0x7f999fedc33ap PyObject_Call + 106 [ ]