diff options
author | 2018-09-27 13:18:33 -0700 | |
---|---|---|
committer | 2018-09-27 13:23:04 -0700 | |
commit | 4cedc8b6e738b7a188c9c091cf667bacafae44b7 (patch) | |
tree | 56de35940e5f9daedd5f39a82d2cd90cf374e4e4 /tensorflow/python/debug | |
parent | c898e63d07fc63315be98f0772736e5d7f2fb44c (diff) |
Updating the V2 variables API.
PiperOrigin-RevId: 214824023
Diffstat (limited to 'tensorflow/python/debug')
11 files changed, 107 insertions, 107 deletions
diff --git a/tensorflow/python/debug/cli/analyzer_cli_test.py b/tensorflow/python/debug/cli/analyzer_cli_test.py index 4630bda590..f197a9e4dc 100644 --- a/tensorflow/python/debug/cli/analyzer_cli_test.py +++ b/tensorflow/python/debug/cli/analyzer_cli_test.py @@ -599,11 +599,11 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): v_name = "simple_mul_add/v" u_init = constant_op.constant(u_init_val, shape=[2, 2], name="u_init") - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) cls._u_line_number = line_number_above() v_init = constant_op.constant(v_init_val, shape=[2, 1], name="v_init") - v = variables.Variable(v_init, name=v_name) + v = variables.VariableV1(v_init, name=v_name) cls._v_line_number = line_number_above() w = math_ops.matmul(u, v, name="simple_mul_add/matmul") @@ -612,7 +612,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): x = math_ops.add(w, w, name="simple_mul_add/add") cls._x_line_number = line_number_above() - a = variables.Variable([1, 3, 3, 7], name="a") + a = variables.VariableV1([1, 3, 3, 7], name="a") u.initializer.run() v.initializer.run() @@ -1371,7 +1371,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): # Verify the annotation of the line that creates u. index = self._findSourceLine(out, self._u_line_number) self.assertEqual( - ["L%d u = variables.Variable(u_init, name=u_name)" % + ["L%d u = variables.VariableV1(u_init, name=u_name)" % self._u_line_number, " simple_mul_add/u", " simple_mul_add/u/Assign", @@ -1388,7 +1388,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): # Verify the annotation of the line that creates v. index = self._findSourceLine(out, self._v_line_number) self.assertEqual( - ["L%d v = variables.Variable(v_init, name=v_name)" % + ["L%d v = variables.VariableV1(v_init, name=v_name)" % self._v_line_number, " simple_mul_add/v"], out.lines[index : index + 2]) @@ -1425,7 +1425,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): # Verify the annotation of the line that creates u. index = self._findSourceLine(out, self._u_line_number) self.assertEqual( - ["L%d u = variables.Variable(u_init, name=u_name)" % + ["L%d u = variables.VariableV1(u_init, name=u_name)" % self._u_line_number, " simple_mul_add/u/read:0", " simple_mul_add/u:0"], @@ -1447,7 +1447,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): index = self._findSourceLine(out, self._u_line_number) self.assertEqual( - ["L%d u = variables.Variable(u_init, name=u_name)" % + ["L%d u = variables.VariableV1(u_init, name=u_name)" % self._u_line_number, " simple_mul_add/u", " simple_mul_add/u/Assign", @@ -1470,7 +1470,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): index = self._findSourceLine(out, self._u_line_number) self.assertEqual( - ["L%d u = variables.Variable(u_init, name=u_name)" % + ["L%d u = variables.VariableV1(u_init, name=u_name)" % self._u_line_number, " simple_mul_add/u", " (... Omitted 2 of 3 op(s) ...) +5"], @@ -1580,7 +1580,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): """List an input tree containing tensors from non-:0 output slot.""" with session.Session(config=no_rewrite_session_config()) as sess: - x = variables.Variable([1, 3, 3, 7], name="x") + x = variables.VariableV1([1, 3, 3, 7], name="x") _, idx = array_ops.unique(x, name="x_unique") idx_times_two = math_ops.multiply(idx, 2, name="idx_times_two") sess.run(x.initializer) @@ -1684,7 +1684,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase): with session.Session(config=no_rewrite_session_config()) as sess: x_init_val = np.array([5.0, 3.0]) x_init = constant_op.constant(x_init_val, shape=[2]) - x = variables.Variable(x_init, name="control_deps/x") + x = variables.VariableV1(x_init, name="control_deps/x") y = math_ops.add(x, x, name="control_deps/y") y = control_flow_ops.with_dependencies( diff --git a/tensorflow/python/debug/cli/stepper_cli_test.py b/tensorflow/python/debug/cli/stepper_cli_test.py index ee8cabca0d..7b8a42c253 100644 --- a/tensorflow/python/debug/cli/stepper_cli_test.py +++ b/tensorflow/python/debug/cli/stepper_cli_test.py @@ -132,8 +132,8 @@ def _parse_updated(lines): class NodeStepperSimpleGraphTest(test_util.TensorFlowTestCase): def setUp(self): - self.a = variables.Variable(10.0, name="a") - self.b = variables.Variable(20.0, name="b") + self.a = variables.VariableV1(10.0, name="a") + self.b = variables.VariableV1(20.0, name="b") self.c = math_ops.add(self.a, self.b, name="c") # Should be 30.0. self.d = math_ops.subtract(self.a, self.c, name="d") # Should be -20.0. diff --git a/tensorflow/python/debug/lib/debug_utils_test.py b/tensorflow/python/debug/lib/debug_utils_test.py index 5b1875e092..23ab98444c 100644 --- a/tensorflow/python/debug/lib/debug_utils_test.py +++ b/tensorflow/python/debug/lib/debug_utils_test.py @@ -46,8 +46,8 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): cls._b_init = constant_op.constant( cls._b_init_val, shape=[2, 1], name="b_init") - cls._a = variables.Variable(cls._a_init, name="a1") - cls._b = variables.Variable(cls._b_init, name="b") + cls._a = variables.VariableV1(cls._a_init, name="a1") + cls._b = variables.VariableV1(cls._b_init, name="b") cls._c = constant_op.constant(cls._c_val, shape=[2, 1], name="c") # Matrix product of a and b. diff --git a/tensorflow/python/debug/lib/dist_session_debug_grpc_test.py b/tensorflow/python/debug/lib/dist_session_debug_grpc_test.py index 46a7be5808..74498c8ea3 100644 --- a/tensorflow/python/debug/lib/dist_session_debug_grpc_test.py +++ b/tensorflow/python/debug/lib/dist_session_debug_grpc_test.py @@ -118,8 +118,8 @@ class DistributedSessionDebugTest(test_util.TensorFlowTestCase): """ with ops.Graph().as_default() as graph: with ops.device("/job:worker/task:0/cpu:0"): - self.a = variables.Variable(10.0, name="a") - self.b = variables.Variable(100.0, name="b") + self.a = variables.VariableV1(10.0, name="a") + self.b = variables.VariableV1(100.0, name="b") self.inc_a = state_ops.assign_add(self.a, 2.0, name="inc_a") self.dec_b = state_ops.assign_add(self.b, -5.0, name="dec_b") self.p = math_ops.multiply(self.inc_a, self.dec_b, name="p") diff --git a/tensorflow/python/debug/lib/grpc_large_data_test.py b/tensorflow/python/debug/lib/grpc_large_data_test.py index 5bc477a9ba..ccc21bcf94 100644 --- a/tensorflow/python/debug/lib/grpc_large_data_test.py +++ b/tensorflow/python/debug/lib/grpc_large_data_test.py @@ -61,7 +61,7 @@ class LargeGraphAndLargeTensorsDebugTest(test_util.TensorFlowTestCase): with self.test_session( use_gpu=True, config=session_debug_testlib.no_rewrite_session_config()) as sess: - u = variables.Variable(42.0, name="original_u") + u = variables.VariableV1(42.0, name="original_u") for _ in xrange(50 * 1000): u = array_ops.identity(u) sess.run(variables.global_variables_initializer()) @@ -94,7 +94,7 @@ class LargeGraphAndLargeTensorsDebugTest(test_util.TensorFlowTestCase): u_init = constant_op.constant( u_init_val_array, dtype=dtypes.float32, name="u_init") - u = variables.Variable(u_init, name="u") + u = variables.VariableV1(u_init, name="u") def watch_fn(fetches, feeds): del fetches, feeds # Unused by this watch_fn. @@ -117,7 +117,7 @@ class LargeGraphAndLargeTensorsDebugTest(test_util.TensorFlowTestCase): b"", b"spam", b"A" * 2500 * 1024, b"B" * 2500 * 1024, b"egg", b""] u_init = constant_op.constant( u_init_val, dtype=dtypes.string, name="u_init") - u = variables.Variable(u_init, name="u") + u = variables.VariableV1(u_init, name="u") def watch_fn(fetches, feeds): del fetches, feeds @@ -146,7 +146,7 @@ class LargeGraphAndLargeTensorsDebugTest(test_util.TensorFlowTestCase): u_init = constant_op.constant( u_init_val_array, dtype=dtypes.string, name="u_init") - u = variables.Variable(u_init, name="u") + u = variables.VariableV1(u_init, name="u") def watch_fn(fetches, feeds): del fetches, feeds @@ -167,7 +167,7 @@ class LargeGraphAndLargeTensorsDebugTest(test_util.TensorFlowTestCase): config=session_debug_testlib.no_rewrite_session_config()) as sess: u_init = constant_op.constant( [], dtype=dtypes.float32, shape=[0], name="u_init") - u = variables.Variable(u_init, name="u") + u = variables.VariableV1(u_init, name="u") def watch_fn(fetches, feeds): del fetches, feeds @@ -189,7 +189,7 @@ class LargeGraphAndLargeTensorsDebugTest(test_util.TensorFlowTestCase): config=session_debug_testlib.no_rewrite_session_config()) as sess: u_init = constant_op.constant( [], dtype=dtypes.string, shape=[0], name="u_init") - u = variables.Variable(u_init, name="u") + u = variables.VariableV1(u_init, name="u") def watch_fn(fetches, feeds): del fetches, feeds diff --git a/tensorflow/python/debug/lib/session_debug_file_test.py b/tensorflow/python/debug/lib/session_debug_file_test.py index ba0f15b4e2..1874160dd6 100644 --- a/tensorflow/python/debug/lib/session_debug_file_test.py +++ b/tensorflow/python/debug/lib/session_debug_file_test.py @@ -58,9 +58,9 @@ class SessionDebugFileTest(session_debug_testlib.SessionDebugTestBase): v_name = "diff_Watch/v" u_init = constant_op.constant(u_init_val, shape=[2, 2]) - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) v_init = constant_op.constant(v_init_val, shape=[2, 1]) - v = variables.Variable(v_init, name=v_name) + v = variables.VariableV1(v_init, name=v_name) w = math_ops.matmul(u, v, name="diff_Watch/matmul") diff --git a/tensorflow/python/debug/lib/session_debug_grpc_test.py b/tensorflow/python/debug/lib/session_debug_grpc_test.py index 91f21cb1f3..bfc9a3a382 100644 --- a/tensorflow/python/debug/lib/session_debug_grpc_test.py +++ b/tensorflow/python/debug/lib/session_debug_grpc_test.py @@ -148,8 +148,8 @@ class SessionDebugGrpcTest(session_debug_testlib.SessionDebugTestBase): sess, "localhost:%d" % self._server_port, watch_fn="foo") def testGrpcDebugWrapperSessionWithoutWatchFnWorks(self): - u = variables.Variable(2.1, name="u") - v = variables.Variable(20.0, name="v") + u = variables.VariableV1(2.1, name="u") + v = variables.VariableV1(20.0, name="v") w = math_ops.multiply(u, v, name="w") sess = session.Session( @@ -175,8 +175,8 @@ class SessionDebugGrpcTest(session_debug_testlib.SessionDebugTestBase): del feeds, fetch_keys return ["DebugIdentity", "DebugNumericSummary"], r".*/read", None - u = variables.Variable(2.1, name="u") - v = variables.Variable(20.0, name="v") + u = variables.VariableV1(2.1, name="u") + v = variables.VariableV1(20.0, name="v") w = math_ops.multiply(u, v, name="w") sess = session.Session( @@ -209,8 +209,8 @@ class SessionDebugGrpcTest(session_debug_testlib.SessionDebugTestBase): op_type_regex_whitelist=None, tolerate_debug_op_creation_failures=True) - u = variables.Variable(2.1, name="u") - v = variables.Variable(20.0, name="v") + u = variables.VariableV1(2.1, name="u") + v = variables.VariableV1(20.0, name="v") w = math_ops.multiply(u, v, name="w") sess = session.Session( @@ -241,8 +241,8 @@ class SessionDebugGrpcTest(session_debug_testlib.SessionDebugTestBase): 14, len(dump.get_tensors("v/read", 0, "DebugNumericSummary")[0])) def testTensorBoardDebugHookWorks(self): - u = variables.Variable(2.1, name="u") - v = variables.Variable(20.0, name="v") + u = variables.VariableV1(2.1, name="u") + v = variables.VariableV1(20.0, name="v") w = math_ops.multiply(u, v, name="w") sess = session.Session( @@ -286,8 +286,8 @@ class SessionDebugGrpcTest(session_debug_testlib.SessionDebugTestBase): self._server.query_source_file_line(__file__, 1) def testTensorBoardDebugHookDisablingTracebackSourceCodeSendingWorks(self): - u = variables.Variable(2.1, name="u") - v = variables.Variable(20.0, name="v") + u = variables.VariableV1(2.1, name="u") + v = variables.VariableV1(20.0, name="v") w = math_ops.multiply(u, v, name="w") sess = session.Session( @@ -381,8 +381,8 @@ class SessionDebugGrpcGatingTest(test_util.TensorFlowTestCase): def testToggleEnableTwoDebugWatchesNoCrosstalkBetweenDebugNodes(self): with session.Session( config=session_debug_testlib.no_rewrite_session_config()) as sess: - v_1 = variables.Variable(50.0, name="v_1") - v_2 = variables.Variable(-50.0, name="v_1") + v_1 = variables.VariableV1(50.0, name="v_1") + v_2 = variables.VariableV1(-50.0, name="v_1") delta_1 = constant_op.constant(5.0, name="delta_1") delta_2 = constant_op.constant(-5.0, name="delta_2") inc_v_1 = state_ops.assign_add(v_1, delta_1, name="inc_v_1") @@ -451,8 +451,8 @@ class SessionDebugGrpcGatingTest(test_util.TensorFlowTestCase): with session.Session( config=session_debug_testlib.no_rewrite_session_config()) as sess: - v_1 = variables.Variable(50.0, name="v_1") - v_2 = variables.Variable(-50.0, name="v_1") + v_1 = variables.VariableV1(50.0, name="v_1") + v_2 = variables.VariableV1(-50.0, name="v_1") # These two nodes have names that match those in the # toggle_watch_on_core_metadata argument used when calling # start_server_on_separate_thread(). @@ -491,7 +491,7 @@ class SessionDebugGrpcGatingTest(test_util.TensorFlowTestCase): def testToggleEnableTwoDebugWatchesNoCrosstalkBetweenServers(self): with session.Session( config=session_debug_testlib.no_rewrite_session_config()) as sess: - v = variables.Variable(50.0, name="v") + v = variables.VariableV1(50.0, name="v") delta = constant_op.constant(5.0, name="delta") inc_v = state_ops.assign_add(v, delta, name="inc_v") @@ -534,8 +534,8 @@ class SessionDebugGrpcGatingTest(test_util.TensorFlowTestCase): def testToggleBreakpointsWorks(self): with session.Session( config=session_debug_testlib.no_rewrite_session_config()) as sess: - v_1 = variables.Variable(50.0, name="v_1") - v_2 = variables.Variable(-50.0, name="v_2") + v_1 = variables.VariableV1(50.0, name="v_1") + v_2 = variables.VariableV1(-50.0, name="v_2") delta_1 = constant_op.constant(5.0, name="delta_1") delta_2 = constant_op.constant(-5.0, name="delta_2") inc_v_1 = state_ops.assign_add(v_1, delta_1, name="inc_v_1") @@ -592,8 +592,8 @@ class SessionDebugGrpcGatingTest(test_util.TensorFlowTestCase): def testTensorBoardDebuggerWrapperToggleBreakpointsWorks(self): with session.Session( config=session_debug_testlib.no_rewrite_session_config()) as sess: - v_1 = variables.Variable(50.0, name="v_1") - v_2 = variables.Variable(-50.0, name="v_2") + v_1 = variables.VariableV1(50.0, name="v_1") + v_2 = variables.VariableV1(-50.0, name="v_2") delta_1 = constant_op.constant(5.0, name="delta_1") delta_2 = constant_op.constant(-5.0, name="delta_2") inc_v_1 = state_ops.assign_add(v_1, delta_1, name="inc_v_1") @@ -665,8 +665,8 @@ class SessionDebugGrpcGatingTest(test_util.TensorFlowTestCase): def testTensorBoardDebuggerWrapperDisablingTracebackSourceSendingWorks(self): with session.Session( config=session_debug_testlib.no_rewrite_session_config()) as sess: - v_1 = variables.Variable(50.0, name="v_1") - v_2 = variables.Variable(-50.0, name="v_2") + v_1 = variables.VariableV1(50.0, name="v_1") + v_2 = variables.VariableV1(-50.0, name="v_2") delta_1 = constant_op.constant(5.0, name="delta_1") delta_2 = constant_op.constant(-5.0, name="delta_2") inc_v_1 = state_ops.assign_add(v_1, delta_1, name="inc_v_1") @@ -699,7 +699,7 @@ class SessionDebugGrpcGatingTest(test_util.TensorFlowTestCase): def testGetGrpcDebugWatchesReturnsCorrectAnswer(self): with session.Session() as sess: - v = variables.Variable(50.0, name="v") + v = variables.VariableV1(50.0, name="v") delta = constant_op.constant(5.0, name="delta") inc_v = state_ops.assign_add(v, delta, name="inc_v") @@ -743,7 +743,7 @@ class DelayedDebugServerTest(test_util.TensorFlowTestCase): with self.cached_session() as sess: a_init = constant_op.constant(42.0, name="a_init") - a = variables.Variable(a_init, name="a") + a = variables.VariableV1(a_init, name="a") def watch_fn(fetches, feeds): del fetches, feeds diff --git a/tensorflow/python/debug/lib/session_debug_testlib.py b/tensorflow/python/debug/lib/session_debug_testlib.py index 070d9c4cd7..25ef91b575 100644 --- a/tensorflow/python/debug/lib/session_debug_testlib.py +++ b/tensorflow/python/debug/lib/session_debug_testlib.py @@ -70,7 +70,7 @@ class _RNNCellForTest(rnn_cell_impl.RNNCell): def __init__(self, input_output_size, state_size): self._input_output_size = input_output_size self._state_size = state_size - self._w = variables.Variable(1.0, dtype=dtypes.float32, name="w") + self._w = variables.VariableV1(1.0, dtype=dtypes.float32, name="w") @property def output_size(self): @@ -182,9 +182,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): w_name = "w" u_init = constant_op.constant(u_init_val, shape=[2, 2]) - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) v_init = constant_op.constant(v_init_val, shape=[2, 1]) - v = variables.Variable(v_init, name=v_name) + v = variables.VariableV1(v_init, name=v_name) w = math_ops.matmul(u, v, name=w_name) @@ -221,8 +221,8 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testCopyNodesHaveCorrectDebugOpsAndURLsAttributeValues(self): with session.Session() as sess: - u = variables.Variable(2.1, name="u") - v = variables.Variable(20.0, name="v") + u = variables.VariableV1(2.1, name="u") + v = variables.VariableV1(20.0, name="v") w = math_ops.multiply(u, v, name="w") sess.run(variables.global_variables_initializer()) @@ -324,8 +324,8 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): str1_name = "str1" str2_name = "str2" - str1 = variables.Variable(str1_init, name=str1_name) - str2 = variables.Variable(str2_init, name=str2_name) + str1 = variables.VariableV1(str1_init, name=str1_name) + str2 = variables.VariableV1(str2_init, name=str2_name) # Concatenate str1 and str2 str_concat = math_ops.add(str1, str2, name="str_concat") @@ -387,9 +387,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): s_name = "%s/s" % op_namespace u_init = constant_op.constant(u_init_val, shape=[2, 2]) - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) s_init = constant_op.constant(s_init_val) - s = variables.Variable(s_init, name=s_name) + s = variables.VariableV1(s_init, name=s_name) run_options = config_pb2.RunOptions(output_partition_graphs=True) debug_urls = self._debug_urls() @@ -439,7 +439,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): u_init_val = np.array(11.0) u_init = constant_op.constant(u_init_val) - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) # "v" is the increment. v_name = "testDumpToFileWhileLoop/v" @@ -447,7 +447,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): v_init_val = np.array(2.0) v_init = constant_op.constant(v_init_val) - v = variables.Variable(v_init, name=v_name) + v = variables.VariableV1(v_init, name=v_name) u.initializer.run() v.initializer.run() @@ -605,8 +605,8 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testDebugCondWatchingWholeGraphWorks(self): with session.Session() as sess: - x = variables.Variable(10.0, name="x") - y = variables.Variable(20.0, name="y") + x = variables.VariableV1(10.0, name="x") + y = variables.VariableV1(20.0, name="y") cond = control_flow_ops.cond( x > y, lambda: math_ops.add(x, 1), lambda: math_ops.add(y, 1)) @@ -628,9 +628,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): z_name = "testFindNodesWithBadTensorValues/z" u_init = constant_op.constant([2.0, 4.0]) - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) v_init = constant_op.constant([2.0, 1.0]) - v = variables.Variable(v_init, name=v_name) + v = variables.VariableV1(v_init, name=v_name) # Expected output: [0.0, 3.0] w = math_ops.subtract(u, v, name=w_name) @@ -679,9 +679,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): z_name = "testFindInfOrNanWithOpNameExclusion/z" u_init = constant_op.constant([2.0, 4.0]) - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) v_init = constant_op.constant([2.0, 1.0]) - v = variables.Variable(v_init, name=v_name) + v = variables.VariableV1(v_init, name=v_name) # Expected output: [0.0, 3.0] w = math_ops.subtract(u, v, name=w_name) @@ -725,7 +725,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): w_name = "testDumpGraphStructureLookup/w" u_init = constant_op.constant([2.0, 4.0]) - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) v = math_ops.add(u, u, name=v_name) w = math_ops.add(v, v, name=w_name) @@ -859,9 +859,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testGraphPathFindingOnControlEdgesWorks(self): with session.Session(config=no_rewrite_session_config()) as sess: - v1 = variables.Variable(1.0, name="v1") - v2 = variables.Variable(2.0, name="v2") - v3 = variables.Variable(3.0, name="v3") + v1 = variables.VariableV1(1.0, name="v1") + v2 = variables.VariableV1(2.0, name="v2") + v3 = variables.VariableV1(3.0, name="v3") a = math_ops.add(v1, v2, name="a") with ops.control_dependencies([a]): c = math_ops.subtract(v3, v3, name="c") @@ -875,8 +875,8 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testGraphPathFindingReverseRefEdgeWorks(self): with session.Session(config=no_rewrite_session_config()) as sess: - v = variables.Variable(10.0, name="v") - delta = variables.Variable(1.0, name="delta") + v = variables.VariableV1(10.0, name="v") + delta = variables.VariableV1(1.0, name="delta") inc_v = state_ops.assign_add(v, delta, name="inc_v") sess.run(variables.global_variables_initializer()) @@ -894,7 +894,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): w_name = "testDumpCausalityCheck/w" u_init = constant_op.constant([2.0, 4.0]) - u = variables.Variable(u_init, name=u_name) + u = variables.VariableV1(u_init, name=u_name) v = math_ops.add(u, u, name=v_name) w = math_ops.add(v, v, name=w_name) @@ -980,7 +980,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): w_name = "oneOfTwoSlots/w" y_name = "oneOfTwoSlots/y" - x = variables.Variable([1, 3, 3, 7], dtype=dtypes.int32, name=x_name) + x = variables.VariableV1([1, 3, 3, 7], dtype=dtypes.int32, name=x_name) sess.run(x.initializer) unique_x, indices, _ = array_ops.unique_with_counts(x, name=u_name) @@ -1039,9 +1039,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): with session.Session(config=no_rewrite_session_config()) as sess: u_init = constant_op.constant(10.0) - u = variables.Variable(u_init, name="gdo/u") + u = variables.VariableV1(u_init, name="gdo/u") v_init = constant_op.constant(20.0) - v = variables.Variable(v_init, name="gdo/v") + v = variables.VariableV1(v_init, name="gdo/v") w = math_ops.multiply(u, v, name="gdo/w") # gdo stands for GradientDescentOptimizer. @@ -1085,7 +1085,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): with session.Session() as sess: x_init = constant_op.constant([2, 2, 3, 5, 5]) - x = variables.Variable(x_init, name="unconnected/x") + x = variables.VariableV1(x_init, name="unconnected/x") # The UniqueOp (tf.unique) has two output slots. Use only slot 0 in the # graph. Let the debugger watch the unused slot 1. @@ -1225,14 +1225,14 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testDebugNumericSummaryOnInitializedTensorGivesCorrectResult(self): with session.Session(config=no_rewrite_session_config()) as sess: - a = variables.Variable( + a = variables.VariableV1( [ np.nan, np.nan, 0.0, 0.0, 0.0, -1.0, -3.0, 3.0, 7.0, -np.inf, -np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.nan, np.nan ], dtype=np.float32, name="numeric_summary/a") - b = variables.Variable( + b = variables.VariableV1( [0.0] * 18, dtype=np.float32, name="numeric_summary/b") c = math_ops.add(a, b, name="numeric_summary/c") @@ -1249,7 +1249,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testDebugNumericSummaryOnUninitializedTensorGivesCorrectResult(self): with session.Session() as sess: - a = variables.Variable( + a = variables.VariableV1( [42], dtype=np.float32, name="numeric_summary_uninit/a") _, dump = self._debug_run_and_get_dump( @@ -1275,9 +1275,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testDebugNumericSummaryFailureIsToleratedWhenOrdered(self): with session.Session() as sess: - a = variables.Variable("1", name="a") - b = variables.Variable("3", name="b") - c = variables.Variable("2", name="c") + a = variables.VariableV1("1", name="a") + b = variables.VariableV1("3", name="b") + c = variables.VariableV1("2", name="c") d = math_ops.add(a, b, name="d") e = math_ops.add(d, c, name="e") @@ -1313,9 +1313,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testDebugNumericSummaryInvalidAttributesStringAreCaught(self): with session.Session(config=no_rewrite_session_config()) as sess: - a = variables.Variable(10.0, name="a") - b = variables.Variable(0.0, name="b") - c = variables.Variable(0.0, name="c") + a = variables.VariableV1(10.0, name="a") + b = variables.VariableV1(0.0, name="b") + c = variables.VariableV1(0.0, name="c") x = math_ops.divide(a, b, name="x") y = math_ops.multiply(x, c, name="y") @@ -1361,9 +1361,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testDebugNumericSummaryMuteOnHealthyMutesOnlyHealthyTensorDumps(self): with session.Session(config=no_rewrite_session_config()) as sess: - a = variables.Variable(10.0, name="a") - b = variables.Variable(0.0, name="b") - c = variables.Variable(0.0, name="c") + a = variables.VariableV1(10.0, name="a") + b = variables.VariableV1(0.0, name="b") + c = variables.VariableV1(0.0, name="c") x = math_ops.divide(a, b, name="x") y = math_ops.multiply(x, c, name="y") @@ -1396,8 +1396,8 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testDebugNumericSummaryMuteOnHealthyAndCustomBoundsWork(self): with session.Session() as sess: - a = variables.Variable([10.0, 10.0], name="a") - b = variables.Variable([10.0, 2.0], name="b") + a = variables.VariableV1([10.0, 10.0], name="a") + b = variables.VariableV1([10.0, 2.0], name="b") x = math_ops.add(a, b, name="x") # [20.0, 12.0] y = math_ops.divide(x, b, name="y") # [2.0, 6.0] @@ -1436,9 +1436,9 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): def testLookUpNodePythonTracebackWorks(self): with session.Session() as sess: u_init = constant_op.constant(10.0) - u = variables.Variable(u_init, name="traceback/u") + u = variables.VariableV1(u_init, name="traceback/u") v_init = constant_op.constant(20.0) - v = variables.Variable(v_init, name="traceback/v") + v = variables.VariableV1(v_init, name="traceback/v") w = math_ops.multiply(u, v, name="traceback/w") @@ -1487,7 +1487,7 @@ class DebugConcurrentRunCallsTest(test_util.TensorFlowTestCase): self.skipTest("No testing concurrent runs on a single GPU.") with session.Session() as sess: - v = variables.Variable(30.0, name="v") + v = variables.VariableV1(30.0, name="v") constants = [] for i in xrange(self._num_concurrent_runs): constants.append(constant_op.constant(1.0, name="c%d" % i)) diff --git a/tensorflow/python/debug/lib/stepper_test.py b/tensorflow/python/debug/lib/stepper_test.py index 9a3d0efabf..3839c67198 100644 --- a/tensorflow/python/debug/lib/stepper_test.py +++ b/tensorflow/python/debug/lib/stepper_test.py @@ -36,8 +36,8 @@ from tensorflow.python.training import gradient_descent class StepperTest(test_util.TensorFlowTestCase): def setUp(self): - self.a = variables.Variable(2.0, name="a") - self.b = variables.Variable(3.0, name="b") + self.a = variables.VariableV1(2.0, name="a") + self.b = variables.VariableV1(3.0, name="b") self.c = math_ops.multiply(self.a, self.b, name="c") # Should be 6.0. self.d = math_ops.multiply(self.a, self.a, name="d") # Should be 4.0. @@ -49,7 +49,7 @@ class StepperTest(test_util.TensorFlowTestCase): # The there nodes x, y and z form a graph with "cross-links" in. I.e., x # and y are both direct inputs to z, but x is also a direct input to y. - self.x = variables.Variable(2.0, name="x") # Should be 2.0 + self.x = variables.VariableV1(2.0, name="x") # Should be 2.0 self.y = math_ops.negative(self.x, name="y") # Should be -2.0. self.z = math_ops.multiply(self.x, self.y, name="z") # Should be -4.0. @@ -580,7 +580,7 @@ class StepperTestWithPlaceHolders(test_util.TensorFlowTestCase): class StepperAssignAddTest(test_util.TensorFlowTestCase): def setUp(self): - self.v = variables.Variable(10.0, name="v") + self.v = variables.VariableV1(10.0, name="v") self.p = math_ops.add(self.v, self.v, name="p") self.q = math_ops.multiply(self.p, self.p, name="q") self.delta = constant_op.constant(2.0, name="delta") @@ -711,9 +711,9 @@ class StepperBackwardRunTest(test_util.TensorFlowTestCase): Construct a backward graph using the GradientDescentOptimizer. """ - self.a = variables.Variable(1.0, name="a") - self.b = variables.Variable(2.0, name="b") - self.c = variables.Variable(4.0, name="c") + self.a = variables.VariableV1(1.0, name="a") + self.b = variables.VariableV1(2.0, name="b") + self.c = variables.VariableV1(4.0, name="c") self.d = math_ops.multiply(self.a, self.b, name="d") self.e = math_ops.multiply(self.b, self.c, name="e") self.f = math_ops.multiply(self.d, self.e, name="f") diff --git a/tensorflow/python/debug/wrappers/dumping_wrapper_test.py b/tensorflow/python/debug/wrappers/dumping_wrapper_test.py index 254201c393..11011a5c13 100644 --- a/tensorflow/python/debug/wrappers/dumping_wrapper_test.py +++ b/tensorflow/python/debug/wrappers/dumping_wrapper_test.py @@ -46,7 +46,7 @@ class DumpingDebugWrapperSessionTest(test_util.TensorFlowTestCase): def setUp(self): self.session_root = tempfile.mkdtemp() - self.v = variables.Variable(10.0, dtype=dtypes.float32, name="v") + self.v = variables.VariableV1(10.0, dtype=dtypes.float32, name="v") self.delta = constant_op.constant(1.0, dtype=dtypes.float32, name="delta") self.eta = constant_op.constant(-1.4, dtype=dtypes.float32, name="eta") self.inc_v = state_ops.assign_add(self.v, self.delta, name="inc_v") diff --git a/tensorflow/python/debug/wrappers/local_cli_wrapper_test.py b/tensorflow/python/debug/wrappers/local_cli_wrapper_test.py index 05c9eaa4d2..149a7497df 100644 --- a/tensorflow/python/debug/wrappers/local_cli_wrapper_test.py +++ b/tensorflow/python/debug/wrappers/local_cli_wrapper_test.py @@ -132,8 +132,8 @@ class LocalCLIDebugWrapperSessionTest(test_util.TensorFlowTestCase): def setUp(self): self._tmp_dir = tempfile.mktemp() - self.v = variables.Variable(10.0, name="v") - self.w = variables.Variable(21.0, name="w") + self.v = variables.VariableV1(10.0, name="v") + self.w = variables.VariableV1(21.0, name="w") self.delta = constant_op.constant(1.0, name="delta") self.inc_v = state_ops.assign_add(self.v, self.delta, name="inc_v") @@ -358,7 +358,7 @@ class LocalCLIDebugWrapperSessionTest(test_util.TensorFlowTestCase): def testDebuggingMakeCallableTensorRunnerWorks(self): wrapped_sess = LocalCLIDebuggerWrapperSessionForTest( [["run"], ["run"]], self.sess, dump_root=self._tmp_dir) - v = variables.Variable(42) + v = variables.VariableV1(42) tensor_runner = wrapped_sess.make_callable(v) self.sess.run(v.initializer) @@ -382,7 +382,7 @@ class LocalCLIDebugWrapperSessionTest(test_util.TensorFlowTestCase): def testDebuggingMakeCallableOperationRunnerWorks(self): wrapped_sess = LocalCLIDebuggerWrapperSessionForTest( [["run"], ["run"]], self.sess, dump_root=self._tmp_dir) - v = variables.Variable(10.0) + v = variables.VariableV1(10.0) inc_v = state_ops.assign_add(v, 1.0) op_runner = wrapped_sess.make_callable(inc_v.op) self.sess.run(v.initializer) @@ -403,7 +403,7 @@ class LocalCLIDebugWrapperSessionTest(test_util.TensorFlowTestCase): self.assertEqual(1, len(wrapped_sess.observers["debug_dumps"])) def testDebuggingMakeCallableFromOptionsWithZeroFeedWorks(self): - variable_1 = variables.Variable( + variable_1 = variables.VariableV1( 10.5, dtype=dtypes.float32, name="variable_1") a = math_ops.add(variable_1, variable_1, "callable_a") math_ops.add(a, a, "callable_b") @@ -480,7 +480,7 @@ class LocalCLIDebugWrapperSessionTest(test_util.TensorFlowTestCase): self.assertItemsEqual(["callable_a", "callable_b"], node_names) def testDebugMakeCallableFromOptionsWithCustomOptionsAndMetadataWorks(self): - variable_1 = variables.Variable( + variable_1 = variables.VariableV1( 10.5, dtype=dtypes.float32, name="variable_1") a = math_ops.add(variable_1, variable_1, "callable_a") math_ops.add(a, a, "callable_b") @@ -528,7 +528,7 @@ class LocalCLIDebugWrapperSessionTest(test_util.TensorFlowTestCase): def testRuntimeErrorBeforeGraphExecutionIsRaised(self): # Use an impossible device name to cause an error before graph execution. with ops.device("/device:GPU:1337"): - w = variables.Variable([1.0] * 10, name="w") + w = variables.VariableV1([1.0] * 10, name="w") wrapped_sess = LocalCLIDebuggerWrapperSessionForTest( [["run"]], self.sess, dump_root=self._tmp_dir) |