我已经用wget下载了数据
!wget http://nlp.stanford.edu/data/glove.6B.zip
- ‘glove.6B.zip’ saved [862182613/862182613]
它保存为 zip,我想使用 zip 文件中的 glove.6B.300d.txt 文件。我想要实现的是:
embeddings_index = {}
with io.open('glove.6B.300d.txt', encoding='utf8') as f:
for line in f:
values = line.split()
word = values[0]
coefs = np.asarray(values[1:],dtype='float32')
embeddings_index[word] = coefs
当然我有这个错误:
IOErrorTraceback (most recent call last)
<ipython-input-47-d07cafc85c1c> in <module>()
1 embeddings_index = {}
----> 2 with io.open('glove.6B.300d.txt', encoding='utf8') as f:
3 for line in f:
4 values = line.split()
5 word = values[0]
IOError: [Errno 2] No such file or directory: 'glove.6B.300d.txt'
我如何在 Google colab 上面的代码中解压缩并使用该文件?
原文由 beginner 发布,翻译遵循 CC BY-SA 4.0 许可协议
很简单,查看来自 SO 的旧帖子。