在加载稀疏矩阵时出错。
item_item_sparse.npz是存储在我的cwd(当前工作目录)中的稀疏矩阵。无法理解为什么会出现此错误。 该文件已经存在于我的目录中,并且显示了我得到的完整跟踪错误。
如果有人知道为什么会出现错误。请帮帮我。我已经检查了stackoverflow中的类似错误,但没有一个有用。
item_sim_sparse = sparse.load_npz("item_item_sim_sparse.npz")
error Traceback (most recent call last)
<ipython-input-22-c842b121c6e9> in <module>()
11 else:
12 print("It is there, We will get it.")
---> 13 item_sim_sparse = sparse.load_npz("item_item_sparse.npz")
14 print("Done ...")
15
~/anaconda3/lib/python3.6/site-packages/scipy/sparse/_matrix_io.py in load_npz(file)
147
148 if matrix_format in ('csc', 'csr', 'bsr'):
--> 149 return cls((loaded['data'], loaded['indices'], loaded['indptr']), shape=loaded['shape'])
150 elif matrix_format == 'dia':
151 return cls((loaded['data'], loaded['offsets']), shape=loaded['shape'])
~/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py in __getitem__(self, key)
233 return format.read_array(bytes,
234 allow_pickle=self.allow_pickle,
--> 235 pickle_kwargs=self.pickle_kwargs)
236 else:
237 return self.zip.read(key)
~/anaconda3/lib/python3.6/site-packages/numpy/lib/format.py in read_array(fp, allow_pickle, pickle_kwargs)
678 read_count = min(max_read_count, count - i)
679 read_size = int(read_count * dtype.itemsize)
--> 680 data = _read_bytes(fp, read_size, "array data")
681 array[i:i+read_count] = numpy.frombuffer(data, dtype=dtype,
682 count=read_count)
~/anaconda3/lib/python3.6/site-packages/numpy/lib/format.py in _read_bytes(fp, size, error_template)
817 # done about that. note that regular files can't be non-blocking
818 try:
--> 819 r = fp.read(size - len(data))
820 data += r
821 if len(r) == 0 or len(data) == size:
~/anaconda3/lib/python3.6/zipfile.py in read(self, n)
847 self._offset = 0
848 while n > 0 and not self._eof:
--> 849 data = self._read1(n)
850 if n < len(data):
851 self._readbuffer = data
~/anaconda3/lib/python3.6/zipfile.py in _read1(self, n)
923 elif self._compress_type == ZIP_DEFLATED:
924 n = max(n, self.MIN_READ_SIZE)
--> 925 data = self._decompressor.decompress(data, n)
926 self._eof = (self._decompressor.eof or
927 self._compress_left <= 0 and
error: Error -3 while decompressing data: invalid code lengths set