[英]glove = pickle.load(f) EOFError: Ran out of input
So here: 所以在这里:
glove_path = './embeddings/glove_{}_{}.pkl'.format(dataset,mode)
if(os.path.isfile(glove_path)):
print("Reusing glove dictionary to save time")
#with open(glove_path,'r') as f:
with open(glove_path, 'rb') as f: #python 3 for pickle byte size object is needed not str
glove = pickle.load(f)
save = False
If I try 如果我尝试
with open(glove_path,'r') as f:
I get the following error: 我收到以下错误:
Reusing glove dictionary to save time
Traceback (most recent call last):
File "prepare.py", line 315, in <module>
glove = pickle.load(f)
TypeError: a bytes-like object is required, not 'str'
and if I try 如果我尝试
with open(glove_path, 'rb') as f: #python 3 for pickle byte size object is needed not str
I get the following error: 我收到以下错误:
Reusing glove dictionary to save time
Traceback (most recent call last):
File "prepare.py", line 315, in <module>
glove = pickle.load(f)
EOFError: Ran out of input
Can you please guide how to fix this? 你能指导如何解决这个问题吗?
I am using the code from https://github.com/vanzytay/pytorch_sentiment_rnn and using Anaconda Python 3.6
. 我正在使用https://github.com/vanzytay/pytorch_sentiment_rnn中的代码,并使用
Anaconda Python 3.6
。
I have imported pickle like 我有进口泡菜
import six; from six.moves import cPickle as pickle #import compatability with Python 2 using six
while it was originally imported as: 它最初被导入为:
import cPickle as pickle #python 2
"EOFError: Ran out of input" means that you are trying to read empty file. “ EOFError:超出输入范围”表示您正在尝试读取空文件。 Check if file that you are trying to read from is not empty.
检查您要读取的文件是否不为空。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.