fluid下缺乏正则项示例
Created by: jshower
你好,我在进行fulid下的实验时,没有找到fulid下使用正则项的例子。能否提供一个使用正则项的例子,感觉还是很有必要的。 我试着用了一下正则项
optimizer = fluid.optimizer.Momentum(
momentum=0.0,
learning_rate=2e-4,
regularization=fluid.regularizer.L2DecayRegularizer(regularization_coeff=0.1)
)
结果爆出了后面的错误。
Traceback (most recent call last):
File "train.py", line 136, in <module>
num_passes=1000)
File "train.py", line 72, in main
sgd_optimizer.minimize(avg_cost)
File "/usr/local/lib/python2.7/dist-packages/paddle/v2/fluid/optimizer.py", line 234, in minimize
self.regularization)
File "/usr/local/lib/python2.7/dist-packages/paddle/v2/fluid/regularizer.py", line 65, in append_regularization_ops
outputs={"Out": grad})
File "/usr/local/lib/python2.7/dist-packages/paddle/v2/fluid/framework.py", line 801, in append_op
op = Operator(self, op_desc, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/paddle/v2/fluid/framework.py", line 501, in __init__
self.desc.infer_shape(self.block.desc)
paddle.v2.fluid.core.EnforceNotMet: enforce x_dim.size() >= y_dim.size() failed, 1 < 2