Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

python 3 str decode bugfix #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions seq2seq/test/hooks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class TestPrintModelAnalysisHook(tf.test.TestCase):
def test_begin(self):
model_dir = tempfile.mkdtemp()
outfile = tempfile.NamedTemporaryFile()
tf.get_variable("weigths", [128, 128])
tf.get_variable("weights", [128, 128])
hook = hooks.PrintModelAnalysisHook(
params={}, model_dir=model_dir, run_config=tf.contrib.learn.RunConfig())
hook.begin()

with gfile.GFile(os.path.join(model_dir, "model_analysis.txt")) as file:
file_contents = file.read().strip()
file_contents = tf.compat.as_text(file.read()).strip()

self.assertEqual(file_contents.decode(), "_TFProfRoot (--/16.38k params)\n"
" weigths (128x128, 16.38k/16.38k params)")
self.assertEqual(file_contents, "_TFProfRoot (--/16.38k params)\n"
" weights (128x128, 16.38k/16.38k params)")
outfile.close()


Expand Down Expand Up @@ -94,7 +94,7 @@ def test_sampling(self):
outfile = os.path.join(self.sample_dir, "samples_000000.txt")
with open(outfile, "rb") as readfile:
self.assertIn("Prediction followed by Target @ Step 0",
readfile.read().decode("utf-8"))
tf.compat.as_text(readfile.read()))

# Should not trigger for step 9
sess.run(tf.assign(global_step, 9))
Expand All @@ -108,7 +108,7 @@ def test_sampling(self):
outfile = os.path.join(self.sample_dir, "samples_000010.txt")
with open(outfile, "rb") as readfile:
self.assertIn("Prediction followed by Target @ Step 10",
readfile.read().decode("utf-8"))
tf.compat.as_text(readfile.read()))


class TestMetadataCaptureHook(tf.test.TestCase):
Expand All @@ -125,7 +125,7 @@ def tearDown(self):
def test_capture(self):
global_step = tf.contrib.framework.get_or_create_global_step()
# Some test computation
some_weights = tf.get_variable("weigths", [2, 128])
some_weights = tf.get_variable("weights", [2, 128])
computation = tf.nn.softmax(some_weights)

hook = hooks.MetadataCaptureHook(
Expand Down