caicloud / tensorflow-tutorial

Example TensorFlow codes and Caicloud TensorFlow as a Service dev environment.
2.93k stars 2.08k forks source link

第八章循环神经网络中的 reader.py 会报错 #62

Closed liuslnlp closed 6 years ago

liuslnlp commented 7 years ago

环境: Win10 x64 + Tensorflow 1.0.0 + Python 3.6 错误文件位置: Deep_Learning_with_TensorFlow/1.0.0/Chapter08/reader.py 报错内容:

28 def _read_words(filename):
     29   with tf.gfile.GFile(filename, "r") as f:
---> 30     return f.read().decode("utf-8").replace("\n", "<eos>").split()
     31 
     32 

AttributeError: 'str' object has no attribute 'decode'

原内容

def _read_words(filename):
  with tf.gfile.GFile(filename, "r") as f:
    return f.read().decode("utf-8").replace("\n", "<eos>").split()

建议修改为

def _read_words(filename):
  with tf.gfile.GFile(filename, "r") as f:
    return f.read().replace("\n", "<eos>").split()
perhapszzy commented 7 years ago

该repo的代码都是基于python2.7,可能会和python 3有不兼容的地方

caicloud-bot commented 6 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

/lifecycle stale

caicloud-bot commented 6 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

caicloud-bot commented 6 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

/close