Optimizer minimize 报错
Created by: xcwei
self.weights = {
'wq' : fluid.layers.create_parameter(shape = [self.data.n_qfeature, self.data.n_feature_1 + self.data.n_feature_2], dtype = 'float32', default_initializer = fluid.initializer.Uniform(seed = self.seed), name = 'wq'),
'bq' : fluid.layers.create_parameter(shape = [self.data.n_feature_1 + self.data.n_feature_2], dtype = 'float32', default_initializer = fluid.initializer.ConstantInitializer(value = 0.0), name = 'bq'),
'wu1' : fluid.layers.create_parameter(shape = [self.data.n_feature_1, self.data.n_feature_2], dtype = 'float32', default_initializer = fluid.initializer.Uniform(seed = self.seed), name = 'wu1'),
'bu1' : fluid.layers.create_parameter(shape = [self.data.n_feature_2], dtype = 'float32', default_initializer = fluid.initializer.ConstantInitializer(value = 1.0), name = 'bu1'),
'wu2' : fluid.layers.create_parameter(shape = [self.data.n_feature_2], dtype = 'float32', default_initializer = fluid.initializer.Uniform(seed = self.seed), name = 'wu2')
}
self.norm_loss = self.lambda_q * fluid.layers.reduce_sum(self.weights['wq'] ** 2) \
+ self.lambda_bq * fluid.layers.reduce_sum(self.weights['bq'] ** 2) \
+ self.lambda_u1 * fluid.layers.reduce_sum(self.weights['wu1'] ** 2) \
+ self.lambda_bu1 * fluid.layers.reduce_sum(self.weights['bu1'] ** 2) \
+ self.lambda_u2 * fluid.layers.reduce_sum(self.weights['wu2'] ** 2)
self.optim = fluid.optimizer.AdagradOptimizer(learning_rate=self.lr)
self.optim.minimize(self.norm_loss)
运行时报错 Traceback (most recent call last): File "Model_QFeatNorm-mod.py", line 128, in model = Model(data) File "Model_QFeatNorm-mod.py", line 32, in init self.build_model() File "Model_QFeatNorm-mod.py", line 40, in build_model self.build_loss() File "Model_QFeatNorm-mod.py", line 99, in build_loss self.optim.minimize(self.norm_loss) File "/home/ssd5/gaoyuan14/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/optimizer.py", line 256, in minimize [error_clip_callback]) File "/home/ssd5/gaoyuan14/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/backward.py", line 564, in append_backward grad_to_var, callbacks) File "/home/ssd5/gaoyuan14/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/backward.py", line 349, in append_backward_ops op.desc, no_grad_dict[block.idx], grad_sub_block_list) paddle.fluid.core.EnforceNotMet: grad_op_maker_ should not be null Operator GradOpMaker has not been registered. at [/paddle/paddle/fluid/framework/op_info.h:61] PaddlePaddle Call Stacks: 0 0x7f86ca04cd86p paddle::platform::EnforceNotMet::EnforceNotMet(std::__exception_ptr::exception_ptr, char const*, int) + 486 1 0x7f86ca04f6e9p paddle::framework::OpInfo::GradOpMaker() const + 137 2 0x7f86ca0484c2p 3 0x7f86ca05d884p pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 2596 4 0x7f8723a9e989p PyEval_EvalFrameEx + 28553 5 0x7f8723aa10bdp PyEval_EvalCodeEx + 2061 6 0x7f8723a9e345p PyEval_EvalFrameEx + 26949 7 0x7f8723aa10bdp PyEval_EvalCodeEx + 2061 8 0x7f8723a9e345p PyEval_EvalFrameEx + 26949 9 0x7f8723aa10bdp PyEval_EvalCodeEx + 2061 10 0x7f8723a9e345p PyEval_EvalFrameEx + 26949 11 0x7f8723a9e460p PyEval_EvalFrameEx + 27232 12 0x7f8723a9e460p PyEval_EvalFrameEx + 27232 13 0x7f8723aa10bdp PyEval_EvalCodeEx + 2061 14 0x7f8723a17eb0p 15 0x7f87239e5df3p PyObject_Call + 67 16 0x7f87239f49cdp 17 0x7f87239e5df3p PyObject_Call + 67 18 0x7f8723a97417p PyEval_CallObjectWithKeywords + 71 19 0x7f87239ff7f8p PyInstance_New + 104 20 0x7f87239e5df3p PyObject_Call + 67 21 0x7f8723a9b4a6p PyEval_EvalFrameEx + 15014 22 0x7f8723aa10bdp PyEval_EvalCodeEx + 2061 23 0x7f8723aa11f2p PyEval_EvalCode + 50 24 0x7f8723ac9f42p PyRun_FileExFlags + 146 25 0x7f8723acb2d9p PyRun_SimpleFileExFlags + 217 26 0x7f8723ae100dp Py_Main + 3149 27 0x7f8722cdebd5p __libc_start_main + 245 28 0x4007a1p
请问这是为什么,我是在潜移TF的代码,TF里类似的操作时没问题的