Address an issue with initializing AdamOptimizer.
@@ -61,11 +61,14 @@ class _TensorFlowOptimizer(optimizer.Optimizer):
self._initialize_optimizer(var_list, session)
def _initialize_optimizer(self, var_list, session):
+ # TODO(awav): AdamOptimizer creates beta1 and beta2 variables which are
+ # not included in slots.
+ extra_vars = [v for v in self.optimizer.__dict__.values() if isinstance(v, tf.Variable)]
optimizer_vars = [self.optimizer.get_slot(var, name)
for name in self.optimizer.get_slot_names()
for var in var_list]
- print(optimizer_vars)
- session.run(tf.variables_initializer(optimizer_vars))
+ var_list = list(set(optimizer_vars + extra_vars))
+ session.run(tf.variables_initializer(var_list))
@property
def minimize_operation(self):
