Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occured when using "fluid.optimizer.Momentum" #9024

Closed
BigFishMaster opened this issue Mar 13, 2018 · 1 comment · Fixed by #9158
Closed

An error occured when using "fluid.optimizer.Momentum" #9024

BigFishMaster opened this issue Mar 13, 2018 · 1 comment · Fixed by #9158
Assignees

Comments

@BigFishMaster
Copy link
Contributor

BigFishMaster commented Mar 13, 2018

I use the python code of SE_ResNeXt in issue #8990 . Single card result is ok.
However, when parallel = True, "regularization=fluid.regularizer.L2Decay(1e-4)" can not be used as following:

optimizer = fluid.optimizer.Momentum(
        learning_rate=fluid.layers.piecewise_decay(
            boundaries = bd,
            values = lr
        ),
        momentum=0.9,
        regularization=fluid.regularizer.L2Decay(1e-4))

the error message is:

Traceback (most recent call last):
  File "se_resnext50_parallel.py", line 250, in <module>
    train(learning_rate=0.1, batch_size=256, num_passes=120, init_model=None)
  File "se_resnext50_parallel.py", line 177, in train
    opts = optimizer.minimize(avg_cost)
  File "/home/ssd1/yancanxiang/code_paddle/se_resnext50_parallel_MSRA_imagenet1000/python-gcc482-paddle/lib/python2.7/site-packages/paddle/fluid/optimizer.py", line 230, in minimize
    self.regularization)
  File "/home/ssd1/yancanxiang/code_paddle/se_resnext50_parallel_MSRA_imagenet1000/python-gcc482-paddle/lib/python2.7/site-packages/paddle/fluid/regularizer.py", line 51, in append_regularization_ops
    regularization_term = regularization(param, grad.block)
AttributeError: 'NoneType' object has no attribute 'block'

If I delete this code, It can run nomally.

optimizer = fluid.optimizer.Momentum(
        learning_rate=fluid.layers.piecewise_decay(
            boundaries = bd,
            values = lr
        ),
        momentum=0.9)
@jacquesqiao
Copy link
Member

@BigFishMaster I test on the newest code, the problem does not appear, can you test on the newest code again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants