returning var_list to Optimizer in order
Issue appears to affect only ScipyOptimizer. Does not affect, e.g.,
AdamOptimizer on doc/source/notebook/classification
Appears to be due to the fact that TensorFlow variables are not stably
ordered across across replications, so var_list (and thus random
initial values for optimization) is not either.
@@ -43,7 +43,8 @@ class Optimizer:
@staticmethod
def _gen_var_list(model, var_list):
var_list = var_list or []
- return list(set(model.trainable_tensors).union(var_list))
+ all_vars = list(set(model.trainable_tensors).union(var_list))
+ return sorted(all_vars, key=lambda x: x.name)
@staticmethod
def _gen_feed_dict(model, feed_dict):
