reader.ptb_raw_data 出现 "AttributeError: 'str' object has no attribute 'decode

reader.ptb_raw_data 出现 "AttributeError: 'str' object has no attribute 'decode

reader.ptb_raw_data 出现 "AttributeError: 'str' object has no attribute 'decode

这是因为文件不是unicode编码的,要先以二进制方式打开,读入比特流,再解码。

reader.ptb_raw_data 出现 "AttributeError: 'str' object has no attribute 'decode
将r改为rb
即改之前 with tf.gfile.GFile(filename, "r") as f:
改之后 with tf.gfile.GFile(filename, "rb") as f: #二进制方式打开

reader.ptb_raw_data 出现 "AttributeError: 'str' object has no attribute 'decode