简体   繁体   English

导入 Keras 序列模型时出错

[英]Error in importing Keras sequential model

I have installed keras followed by tensorflow.我已经安装了 keras,然后是 tensorflow。 When I execute keras sequential model, I get an error message stating that当我执行 keras 顺序模型时,我收到一条错误消息,指出

    from keras.models import sequential
    Using TensorFlow backend.
    Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
    ImportError: cannot import name 'sequential'

Changing my comment to the answer.将我的评论更改为答案。

Try Sequential with capital S用大写 S 尝试Sequential

The problem was the lower case s in S equential when you imported it.问题是的小写s S中equential当您导入它。 It should have been - from keras.models import Sequential .However, as a side note, you can use the code from tensorflow.keras import Sequential , using the tensorflow keras api 😊.它应该是 - from keras.models import Sequential但是,作为旁注,您可以使用from tensorflow.keras import Sequential的代码,使用 tensorflow keras api😊。 If you are using colab, you can write %tensorflow_version 2.x at the beginning of your notebook to use version 2 of tensorflow如果你使用的是 colab,你可以在 notebook 开头写%tensorflow_version 2.x来使用 tensorflow 的 version 2

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

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