optimizer.minimize(loss) 报错
Created by: LexiHu
#optimizer.minimize(loss) 报错 模型创建成功,到优化报错optimizer.minimize(loss) 显示,某变量未初始化 #报错信息 Traceback (most recent call last): File "run_classifier.py", line 365, in main(args) File "run_classifier.py", line 129, in main decr_ratio=args.decr_ratio) File "/home/wxy/huzijuan/ERNIE/optimization.py", line 150, in optimization _, param_grads = optimizer.minimize(loss) File "</disk1/lx/conda/envs/pd/lib/python3.7/site-packages/decorator.py:decorator-gen-36>", line 2, in minimize File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(*args, **kwargs) File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/dygraph/base.py", line 78, in impl return func(*args, **kwargs) File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/optimizer.py", line 678, in minimize no_grad_set=no_grad_set) File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/optimizer.py", line 551, in backward no_grad_set, callbacks) File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/backward.py", line 1085, in append_backward append_backward_vars(root_block, fwd_op_num, grad_to_var, grad_info_map) File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/backward.py", line 891, in append_backward_vars op_desc.infer_shape(block.desc) paddle.fluid.core_avx.EnforceNotMet:
C++ Call Stacks (More useful to developers):
0 std::string paddle::platform::GetTraceBackString<std::string const&>(std::string const&, char const*, int) 1 paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const*, int) 2 paddle::operators::Reshape2GradOp::InferShape(paddle::framework::InferShapeContext*) const 3 paddle::framework::OpDesc::InferShape(paddle::framework::BlockDesc const&) const
Python Call Stacks (More useful to users):
File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2488, in append_op attrs=kwargs.get("attrs", None)) File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(*args, **kwargs) File "/disk1/lx/conda/envs/pd/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 9022, in reshape "XShape": x_shape}) File "/home/wxy/huzijuan/ERNIE/my_classifier.py", line 47, in gather_indexes flat_positions = layers.reshape(positions_offseted,[-1]) File "/home/wxy/huzijuan/ERNIE/my_classifier.py", line 164, in create_model ntc_outputs=gather_indexes(seq_ernie_output, pos2) File "run_classifier.py", line 113, in main ernie_config=ernie_config) File "run_classifier.py", line 365, in main(args)
Error Message Summary:
Error: Input(Out@GRAD) shouldn't be null. [Hint: Expected ctx->HasInput(framework::GradVarName("Out")) == true, but received ctx->HasInput(framework::GradVarName("Out")):0 != true:1.] at (/paddle/paddle/fluid/operators/reshape_op.cc:470) [operator < reshape2_grad > error]