【问题标题】:python3 keras import error with both tensorflow and theanotensorflow和theano的python3 keras导入错误
【发布时间】:2020-02-28 09:06:10
【问题描述】:

使用 python3(版本 3.6.8)和 keras 简单的脚本:

import keras

给出一个错误:

使用 TensorFlow 后端。

Ungültiger Maschinenbefehl (Speicherabzug geschrieben)

(在英语中,它类似于:“无效的机器命令(写入内存图像)”)

所以我尝试改用theano:

import os
os.environ['KERAS_BACKEND'] = 'theano'
from keras import backend as K

使用 python3 会显示以下输出:

使用 Theano 后端。

Ungültiger Maschinenbefehl (Speicherabzug geschrieben)

我如何获得有关该问题的更多信息?

【问题讨论】:

    标签: python-3.x tensorflow keras theano


    【解决方案1】:

    试试

    from tensorflow import keras
    

    如果问题仍然存在,请尝试阅读有关如何安装和使用它的文档。

    Keras - Tensorflow

    Keras Overview - Tensorflow

    Keras.io

    【讨论】:

    • 通过此导入,后端消息消失。但错误仍然存​​在。
    • 也许我应该提一下 theano 本身似乎工作正常。所以对我来说,使用 theano 后端会发生同样的错误似乎令人惊讶。
    • 进一步测试表明,tensorflow 导入似乎导致了问题。是不是,keras 在任何情况下都导入了 tensorflow(即使 theano 被明确定义为后端)?
    • 我确实阅读了 tensorflow 安装说明。有一个问题:pip 和 pip3 版本小于 19,我已修复。然后升级了tensorflow,其他的安装需求好像都满足了。无论如何都会发生错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-26
    • 1970-01-01
    • 2022-12-28
    • 2018-11-17
    • 2018-08-15
    • 1970-01-01
    相关资源
    最近更新 更多