Closed xwen99 closed 3 years ago
可以先尝试升级至paddle2.0.0.a0,目前1.8版本中已知elementwise的操作可能会出现问题,在新版本已经修复
Since you haven\'t replied for more than a year, we have closed this issue/pr. If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up. 由于您超过一年未回复,我们将关闭这个issue/pr。 若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。
复现信息:
def adversarial_loss(self, loss): grad = fluid.backward.append_backward(loss, [self.feature.name])[0][1] perturb = _scale_l2(grad, 1.0) adv_loss = self.cl_loss_from_embedding(self.feature + perturb) # 报错在这里
如果交换位置,变成 perturb + self.feature 就不报错
对抗损失 adv_loss 在 build_env 时被加到正常的损失上:
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::ElementwiseOp::InferShape(paddle::framework::InferShapeContext*) const 3 paddle::framework::OpDesc::InferShape(paddle::framework::BlockDesc const&) const
Python Call Stacks (More useful to users):
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2610, in append_op attrs=kwargs.get("attrs", None)) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py", line 242, in impl attrs={'axis': axis}) File "/home/aistudio/work/DuReader-Robust-With-Paddlehub/my_reading_comprehension_task.py", line 520, in adversarial_loss adv_loss = self.cl_loss_from_embedding(self.feature + perturb) File "/home/aistudio/work/DuReader-Robust-With-Paddlehub/my_reading_comprehension_task.py", line 563, in _build_env self.env.adv_loss = self.adversarial_loss(self.loss) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py", line 508, in main_program self._build_env() File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py", line 834, in load_checkpoint main_program=self.main_program) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py", line 367, in init_if_necessary if not self.load_checkpoint(): File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py", line 883, in finetune self.init_if_necessary() File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py", line 868, in finetune_and_eval return self.finetune(do_eval=True) File "reading_comprehension.py", line 104, in
reading_comprehension_task.finetune_and_eval()
Error Message Summary:
NotFoundError: No Input(Y) found for ElementwiseOp operator. [Hint: Expected ctx->HasInput("Y") == true, but received ctx->HasInput("Y"):0 != true:1.] at (/paddle/paddle/fluid/operators/elementwise/elementwise_op.h:42) [operator < elementwise_add > error]