Skip to content

Commit 8712a7f

Browse files
isaprykintensorflower-gardener
authored andcommitted
Internal change.
PiperOrigin-RevId: 191023160
1 parent 28dec7f commit 8712a7f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tensorflow/contrib/optimizer_v2/adagrad.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from __future__ import print_function
2020

2121
from tensorflow.contrib.optimizer_v2 import optimizer_v2
22-
from tensorflow.python.framework import ops
2322
from tensorflow.python.ops import array_ops
2423
from tensorflow.python.ops import gen_array_ops
2524
from tensorflow.python.ops import init_ops
@@ -65,17 +64,18 @@ def __init__(self, learning_rate, initial_accumulator_value=0.1,
6564

6665
def _create_vars(self, var_list, state):
6766
for v in var_list:
68-
with ops.colocate_with(v):
69-
dtype = v.dtype.base_dtype
70-
if v.get_shape().is_fully_defined():
71-
init = init_ops.constant_initializer(self._initial_accumulator_value,
72-
dtype=dtype)
73-
else:
74-
# Use a Tensor instead of initializer if variable does not have static
75-
# shape.
76-
init_constant = gen_array_ops.fill(
77-
array_ops.shape(v), self._initial_accumulator_value)
78-
init = math_ops.cast(init_constant, dtype)
67+
# TODO(isaprykin): Delete colocate_with(v) from other optimizers and
68+
# confirm that colocation will happen anyway.
69+
dtype = v.dtype.base_dtype
70+
if v.get_shape().is_fully_defined():
71+
init = init_ops.constant_initializer(self._initial_accumulator_value,
72+
dtype=dtype)
73+
else:
74+
# Use a Tensor instead of initializer if variable does not have static
75+
# shape.
76+
init_constant = gen_array_ops.fill(
77+
array_ops.shape(v), self._initial_accumulator_value)
78+
init = math_ops.cast(init_constant, dtype)
7979
state.create_slot_with_initializer(v, init, v.get_shape(), dtype,
8080
"accumulator")
8181

0 commit comments

Comments
 (0)