From 3b8bade61776d38686944ce9ebdf9b50e6bb9b9c Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Sat, 24 Feb 2018 17:27:33 +0800 Subject: [PATCH] init learning_rate_map when input learning rate is a Variable --- python/paddle/v2/fluid/optimizer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/paddle/v2/fluid/optimizer.py b/python/paddle/v2/fluid/optimizer.py index 0b3e019d8..9309ec391 100644 --- a/python/paddle/v2/fluid/optimizer.py +++ b/python/paddle/v2/fluid/optimizer.py @@ -45,6 +45,9 @@ class Optimizer(object): # each program should have a independent learning rate # program -> Variable(learning_rate) self._learning_rate_map = defaultdict(lambda: None) + if isinstance(self._learning_rate, framework.Variable): + self._learning_rate_map[framework.default_main_program( + )] = self._learning_rate # Dictionary of accumulators. Some optimizer subclasses need to # allocate and manage extra variables associated with the parameters # to train. These variables are called accumulators. -- GitLab