提交 353c3f51 编写于 作者: G gaotingquan 提交者: Tingquan Gao

debug: when using Piecewise.learning_rate while total epochs < 30

上级 4247fac8
...@@ -406,11 +406,17 @@ class Piecewise(LRBase): ...@@ -406,11 +406,17 @@ class Piecewise(LRBase):
learning_rate=None, learning_rate=None,
**kwargs): **kwargs):
if learning_rate: if learning_rate:
decay_epochs = list(range(0, epochs, 30))[1:] decay_epochs = list(range(0, epochs, 30))
values = [ values = [
learning_rate * (0.1**i) learning_rate * (0.1**i) for i in range(len(decay_epochs))
for i in range(len(decay_epochs) + 1)
] ]
# when total epochs < 30, decay_epochs and values should be
# [] and [lr] respectively, but paddle dont support.
if len(decay_epochs) == 1:
decay_epochs = [epochs]
values = [values[0], values[0]]
else:
decay_epochs = decay_epochs[1:]
logger.warning( logger.warning(
"When 'learning_rate' of Piecewise has beed set, " "When 'learning_rate' of Piecewise has beed set, "
"the learning rate scheduler would be set by the rule that lr decay 10 times every 30 epochs. " "the learning rate scheduler would be set by the rule that lr decay 10 times every 30 epochs. "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册