Commit 286bacf2 authored by ngovanmao's avatar ngovanmao
Browse files

Fix a small bug of Python3 compatibility in tutorial example /rnn/ptb

parent 62b33958
...@@ -21,13 +21,17 @@ from __future__ import print_function ...@@ -21,13 +21,17 @@ from __future__ import print_function
import collections import collections
import os import os
import sys
import tensorflow as tf import tensorflow as tf
def _read_words(filename): def _read_words(filename):
with tf.gfile.GFile(filename, "r") as f: with tf.gfile.GFile(filename, "r") as f:
return f.read().decode("utf-8").replace("\n", "<eos>").split() if sys.version_info[0] >= 3:
return f.read().replace("\n", "<eos>").split()
else:
return f.read().decode("utf-8").replace("\n", "<eos>").split()
def _build_vocab(filename): def _build_vocab(filename):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment