为什么我无法使用 pickle 打开保存的文件

问题描述 投票:0回答:0

我使用 pickle 保存了一个经过训练的 ANN 模型(作为 .sav 文件)。我使用以下脚本打开文件:

filename ='TuneMoveTrain24.sav'
trained_model = pickle.load(open(filename,'rb'))

代码运行良好,但突然出现以下错误:

BadZipFile                                Traceback (most recent call last)
<ipython-input-4-5aa76a0b85f5> in <module>
      1 filename ='TuneMoveTrain24.sav'
----> 2 trained_model = pickle.load(open(filename,'rb'))

5 frames
/usr/lib/python3.8/zipfile.py in _RealGetContents(self)
   1334             raise BadZipFile("File is not a zip file")
   1335         if not endrec:
-> 1336             raise BadZipFile("File is not a zip file")
   1337         if self.debug > 1:
   1338             print(endrec)

BadZipFile: File is not a zip file

知道发生了什么事吗?谢谢。

我尝试使用不同的 PC 但没有解决方案。

python keras deep-learning neural-network pickle
© www.soinside.com 2019 - 2024. All rights reserved.