Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit 83e5949

Browse files
author
Ryan Sepassi
committed
Rm xrange usage from metrics_hook_test
PiperOrigin-RevId: 179882966
1 parent b10286e commit 83e5949

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tensor2tensor/utils/metrics_hook_test.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ def testStop(self):
7474
ckpt_dir = self.ckpt_dir("stop")
7575
dummy = DummyHook(ckpt_dir, every_n_steps=10)
7676
with self.sess(dummy, ckpt_dir) as sess:
77-
for _ in xrange(20):
77+
for _ in range(20):
7878
sess.run(incr_global_step)
7979

8080
# Summary files should now have 2 global step values in them
8181
self.flush()
8282

8383
# Run for 10 more so that the hook gets triggered again
84-
for _ in xrange(10):
84+
for _ in range(10):
8585
sess.run(incr_global_step)
8686

8787
# Check that the metrics have actually been collected.
@@ -93,7 +93,7 @@ def testStop(self):
9393
self.assertTrue(len(steps) >= 2)
9494

9595
# Run for 10 more so that the hook triggers stoppage
96-
for _ in xrange(10):
96+
for _ in range(10):
9797
sess.run(incr_global_step)
9898

9999
with self.assertRaisesRegexp(RuntimeError, "after should_stop requested"):
@@ -117,21 +117,21 @@ def testEarlyStoppingHook(self):
117117
plateau_decrease=False,
118118
every_n_steps=10)
119119
with self.sess(stop_hook, ckpt_dir) as sess:
120-
for _ in xrange(20):
120+
for _ in range(20):
121121
sess.run((incr_global_step, incr_counter))
122122

123123
# Summary files should now have 2 values in them
124124
self.flush()
125125

126126
# Run for more steps so that the hook gets triggered and we verify that we
127127
# don't stop.
128-
for _ in xrange(30):
128+
for _ in range(30):
129129
sess.run((incr_global_step, incr_counter))
130130

131131
self.flush()
132132

133133
# Run without incrementing the counter
134-
for _ in xrange(40):
134+
for _ in range(40):
135135
sess.run(incr_global_step)
136136

137137
# Metrics should be written such that now the counter has gone >20 steps
@@ -140,7 +140,7 @@ def testEarlyStoppingHook(self):
140140

141141
# Check that we ask for stop
142142
with self.assertRaisesRegexp(RuntimeError, "after should_stop requested"):
143-
for _ in xrange(30):
143+
for _ in range(30):
144144
sess.run(incr_global_step)
145145

146146
def testPlateauOpHook(self):
@@ -164,21 +164,21 @@ def testPlateauOpHook(self):
164164
plateau_decrease=False,
165165
every_n_steps=10)
166166
with self.sess(stop_hook, ckpt_dir) as sess:
167-
for _ in xrange(20):
167+
for _ in range(20):
168168
sess.run((incr_global_step, incr_counter))
169169

170170
# Summary files should now have 2 values in them
171171
self.flush()
172172

173173
# Run for more steps so that the hook gets triggered and we verify that we
174174
# don't stop.
175-
for _ in xrange(30):
175+
for _ in range(30):
176176
sess.run((incr_global_step, incr_counter))
177177

178178
self.flush()
179179

180180
# Run without incrementing the counter
181-
for _ in xrange(30):
181+
for _ in range(30):
182182
sess.run(incr_global_step)
183183
self.flush()
184184

@@ -187,8 +187,8 @@ def testPlateauOpHook(self):
187187
# Metrics should be written such that now the counter has gone >20 steps
188188
# without being incremented.
189189
# Check that we run the incr_indicator op several times
190-
for _ in xrange(3):
191-
for _ in xrange(10):
190+
for _ in range(3):
191+
for _ in range(10):
192192
sess.run(incr_global_step)
193193
self.flush()
194194

0 commit comments

Comments
 (0)