提交 44bb9821 编写于 作者: A Aston Zhang

fix textcnn imdb data reading

上级 8691f970
......@@ -9,7 +9,7 @@
本项目是一个开源项目,主要由 `Aston Zhang <https://astonzhang.github.io/>`_ (亚马逊云服务应用科学家)、`李沐 <http://www.cs.cmu.edu/~muli/>`_ (亚马逊云服务首席科学家)、 `Zack Lipton <http://zacklipton.com/>`_ (亚马逊云服务应用科学家,卡内基梅隆大学机器学习系助理教授)、 `Alex Smola <https://alex.smola.org/>`_ (亚马逊云服务总监)和 `来自社区的几十位贡献者 <https://github.com/mli/gluon-tutorials-zh/graphs/contributors>`_ 一起完成。
- `【已有80+贡献者,别忘了提供联系方式】成为本书贡献者,获得专享版赠书并被致谢 <https://discuss.gluon.ai/t/topic/7571>`_。
- `【已有85+贡献者,别忘了提供联系方式】成为本书贡献者,获得专享版赠书并被致谢 <https://discuss.gluon.ai/t/topic/7571>`_。
- `第一季十九课视频汇总 <https://discuss.gluon.ai/t/topic/753>`_ (本教程在不断改进中。最接近视频中的版本是 `v0.6.1 <https://github.com/mli/gluon-tutorials-zh/releases/tag/v0.61>`_)。
......
......@@ -46,8 +46,8 @@ def read_imdb(folder='train'): # 本函数已保存在 gluonbook 包中方便
for label in ['pos', 'neg']:
folder_name = os.path.join('../data/aclImdb/', folder, label)
for file in os.listdir(folder_name):
with open(os.path.join(folder_name, file), 'r') as f:
review = f.read().replace('\n', '').lower()
with open(os.path.join(folder_name, file), 'rb') as f:
review = f.read().decode('utf-8').replace('\n', '').lower()
data.append([review, 1 if label == 'pos' else 0])
random.shuffle(data)
return data
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册