简体   繁体   English

保存加载后keras模型预测为nan

[英]keras model prediction is nan after saving and loading

I trained a neural network with google colab.我用 google colab 训练了一个神经网络。
I saved the neural network using joblib.dump()我使用joblib.dump()保存了神经网络

I then loaded the model on my PC using joblib.load()然后我使用joblib.load()在我的 PC 上加载模型

I made a prediction on the exact same sample, using the same model, on both colab and my PC.我在 colab 和我的 PC 上使用相同的模型对完全相同的样本进行了预测。 On colab, it has an output of [[0.51]] .在 colab 上,它的输出为[[0.51]] On my pc, it has an output of [[nan]] .在我的电脑上,它的输出为[[nan]]

The model summary reports that the architecture of the model is the same.模型摘要报告模型的架构是相同的。 I checked the weights of the model I loaded on my PC, and the model on colab, and the weights are the exact same.我检查了我在 PC 上加载的模型和 colab 上的模型的权重,权重完全相同。

Any ideas as to what I can do?关于我能做什么的任何想法? Thank you.谢谢你。

Quick update: even if I change all of my inputs to zero, the prediction is still nan.快速更新:即使我将所有输入更改为零,预测仍然是nan。

据我所知keras有自己的保存模型的功能比如model.save('file.h5') ,使用joblib库来保存sklearn模型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM