NotFoundError: No Output(X@GRAD) found for BatchNormGrad operator.
[Hint: Expected ctx->HasOutput(framework::GradVarName("X")) == true, but received ctx->HasOutput(framework::GradVarName("X")):0 != true:1.] (at /paddle/paddle/fluid/operators/batch_norm_op.cc:466)
百度aistudio中运行如下代码,在未加batchnorm1d是可以运行的但是加上提示没有梯度
class base_model(fluid.dygraph.Layer): def init(self, classes_num: int): super().init() self.hidden_size = 128 self.batchNorm1d = paddle.nn.BatchNorm1d(5) self.lstm = paddle.nn.LSTM(input_size=20, hidden_size=self.hidden_size, direction="bidirectional")
if name == 'main':
创建模型
0 paddle::imperative::BasicEngine::Execute() 1 paddle::imperative::OpBase::Run(paddle::framework::OperatorBase const&, paddle::imperative::NameVariableWrapperMap const&, paddle::imperative::NameVariableWrapperMap const&, paddle::framework::AttributeMap const&, paddle::platform::Place const&) 2 paddle::imperative::PreparedOp::Run(paddle::imperative::NameVariableWrapperMap const&, paddle::imperative::NameVariableWrapperMap const&, paddle::framework::AttributeMap const&) 3 paddle::operators::BatchNormGradOp::InferShape(paddle::framework::InferShapeContext) const 4 paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const, int) 5 paddle::platform::GetCurrentTraceBackString()
Error Message Summary:
NotFoundError: No Output(X@GRAD) found for BatchNormGrad operator. [Hint: Expected ctx->HasOutput(framework::GradVarName("X")) == true, but received ctx->HasOutput(framework::GradVarName("X")):0 != true:1.] (at /paddle/paddle/fluid/operators/batch_norm_op.cc:466)