我制作了一段可在 Windows 上运行的 Python 深度学习代码原型(prototype),但无法使其在 Linux 上运行。我确定问题来自 load_model。 这是一段在 Windows 和 Linux 中表现不同的 Python 代码。
两个 Keras 安装都是从 Keras Team 的 github 源代码库进行的,因为标准 Keras 包无法识别模型格式,最近为 Github 源代码中的字符格式做了一个补丁。
你知道发生了什么事吗?
代码:
from keras.models import load_model, Model
import sys
import keras
import tensorflow as tf
import os
import platform
print("----------------------------------------------")
print("Operating system:")
print (os.name)
print(platform.system())
print(platform.release())
print("----------------------------------------------")
print("Python version:")
print(sys.version)
print("----------------------------------------------")
print("Tensorflow version: ", tf.__version__)
print("----------------------------------------------")
print("Keras version : ", keras.__version__)
print("----------------------------------------------")
yolo_model = load_model("model.h5")
Windows 输出:
Using TensorFlow backend.
----------------------------------------------
Operating system:
nt
Windows
7
----------------------------------------------
Python version:
3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)]
----------------------------------------------
Tensorflow version: 1.4.0
----------------------------------------------
Keras version : 2.1.2
----------------------------------------------
2018-01-06 21:54:37.700794: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instruc
ions that this TensorFlow binary was not compiled to use: AVX AVX2
C:\Users\David\AppData\Local\Programs\Python\Python36\lib\site-packages\keras-2.1.2-py3.6.egg\keras\models.py:252: UserWarning: No training configuration found
in save file: the model was *not* compiled. Compile it manually.
Linux 输出:
Using TensorFlow backend.
----------------------------------------------
Operating system:
posix
Linux
4.9.0-5-amd64
----------------------------------------------
Python version:
3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118]
----------------------------------------------
Tensorflow version: 1.4.1
----------------------------------------------
Keras version : 2.1.2
----------------------------------------------
----------------------------------------------
2018-01-06 21:47:58.099715: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
Erreur de segmentation
法语Erreur de segmentation的意思是Segmentation fault
感谢您的帮助!
玻璃蛙
最佳答案
我只找到了一个解决方法。
由于模型文件是从另一种格式的另一个权重文件转换而来的数据,我去为最新版本的 Keras 重新生成了 Keras 模型。
现在可以了。
但我仍然不知道是什么导致了段错误。
关于linux - Linux 上的 load_model 上的 Keras 段错误,而不是 Windows 上的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48131965/