错误,TensorSliceReader 构造函数不成功:无法找到 ram 解封文件的任何匹配文件

发布于 2025-01-17 18:22:26 字数 595 浏览 4 评论 0原文

我正在遇到此错误,我无法在jupyter笔记本上删除文件:

import os 
import pickle
import joblib
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
filename = open("loan_model3.pkl", "rb")
mdl = pickle.load(filename)
mdl.close()

它始终显示以下错误消息,甚至我都升级了所有库

错误消息:

filenotfounderror:失败的张量构建器构造函数:未能找到RAM的任何匹配文件:// 89506590-EC42-44A9-B67C-3EE4CC8E4CC8E884E/变量/变量/变量,您可能会尝试从计算设备上加载其他设备上的其他设备。考虑在tf.saved_model.loadoptions中设置pasteriention_io_device选项到io_device,例如'/job:local -host'。

我试图升级图书馆,但仍然没有用。

I am running into this error , i can't unpickle a file on my jupyter notebook:

import os 
import pickle
import joblib
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
filename = open("loan_model3.pkl", "rb")
mdl = pickle.load(filename)
mdl.close()

and it always shows the below error message , even tho i'vce upgraded all my libraries

Error Message:

FileNotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for ram://89506590-ec42-44a9-b67c-3ee4cc8e884e/variables/variables You may be trying to load on a different device from the computational device. Consider setting the experimental_io_deviceoption intf.saved_model.LoadOptions to the io_device such as '/job:localhost'.

I tried to upgrade my libraries but still didn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

不顾 2025-01-24 18:22:26

当我尝试将 Sequential 模型存储在 .pkl 文件中时,我也遇到了同样的错误,因为 Sequential 模型是 TensorFlow Keras 模型,因此我们必须将其存储在 .pkl 文件中。 h5 文件,Keras 以这种格式保存模型,因为它可以轻松地将权重和模型配置存储在单个文件中。

代码:

   from keras.models import load_model
   model.save('model.h5')
   model_final = load_model('model.h5')

I got the same error too when I was trying to store my Sequential model in .pkl file, since Sequential model is a TensorFlow Keras model so we have to store it in .h5 file and Keras saves models in this format as it can easily store the weights and model configuration in a single file.

Code:

   from keras.models import load_model
   model.save('model.h5')
   model_final = load_model('model.h5')
傲鸠 2025-01-24 18:22:26

我不知道你是否还在这里,但我找到了解决方案。基本上你不应该将张量流模型保存到pickle文件中,而是保存到h5文件中

## save model
save_path = './model.h5'
model.save(save_path)
## load tensorflow model
model = keras.models.load_model(save_path)

这对我有用。希望这也对您有帮助。

Idk if you are still here but I found the solution. basically you should not save the tensorflow model into a pickle file but instead into h5 file

## save model
save_path = './model.h5'
model.save(save_path)
## load tensorflow model
model = keras.models.load_model(save_path)

This worked for me. Hope this helps you too.

池木 2025-01-24 18:22:26

这对我有用:

import tensorflow as tf
path = './model.h5'
model.save(path )
loaded_model= tf.keras.models.load_model(path )

this worked for me:

import tensorflow as tf
path = './model.h5'
model.save(path )
loaded_model= tf.keras.models.load_model(path )
海螺姑娘 2025-01-24 18:22:26

我遇到了同样的问题,但是通过将模型保存为.h5文件对我有用。现在,我可以加载.h5型号。

I have faced the same issue, but by saving the model as .h5 file worked for me. Now i'm able to load .h5 model.

找回味觉 2025-01-24 18:22:26

对我来说,当我尝试从子进程返回 Keras 模型时,就会发生这种情况。这是因为进程间通信使用 pickling 来传输对象。

正如其他人所说,酸洗 keras 模型不起作用。

For me, this happened when I tried to return a Keras model from a child process. This is because inter-process communication uses pickling to transfer objects.

As others have stated, pickling keras models doesn't work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文