ValueError Traceback (most recent call last)
Cell In[20], line 1
----> 1 modeel = tf.keras.models.load_model('trained_model.keras')
File c:\Users\arman\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\saving\saving_api.py:193, in load_model(filepath, custom_objects, compile, safe_mode)
189 return legacy_h5_format.load_model_from_hdf5(
190 filepath, custom_objects=custom_objects, compile=compile
191 )
192 elif str(filepath).endswith(".keras"):
--> 193 raise ValueError(
194 f"File not found: filepath={filepath}. "
195 "Please ensure the file is an accessible `.keras` "
196 "zip file."
197 )
198 else:
199 raise ValueError(
200 f"File format not supported: filepath={filepath}. "
201 "Keras 3 only supports V3 `.keras` files and "
(...)
210 "might have a different name)."
211 )
ValueError: File not found: filepath=trained_model.keras. Please ensure the file is an accessible `.keras` zip file.
文件也位于同一目录中。
如何解决这个错误?
您的模型是否保存在您正在使用的同一文件夹中?如果没有,则可以将模型复制到您当前正在使用的文件夹中,或指定已保存模型的完整路径。