如何在 Tensorflow 中导入 keras.engine.topology? [英] How to import keras.engine.topology in Tensorflow?

查看:174
本文介绍了如何在 Tensorflow 中导入 keras.engine.topology?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Tensorflow 中导入 keras.engine.topology.如果我想使用 Keras 的 Tensorflow 版本,我曾经在每次 Keras 导入的开头添加单词 tensorflow.

I want to import keras.engine.topology in Tensorflow. I used to add the word tensorflow at the beginning of every Keras import if I want to use the Tensorflow version of Keras.

例如:而不是写:

from keras.layers import Dense, Dropout, Input

我只是写了下面的代码,它工作正常:

I just write the following code and it works fine :

from tensorflow.keras.layers import Dense, Dropout, Input

但对于这个特定的导入,情况并非如此:

But that's not the case for this specific import:

from tensorflow.keras.engine.topology import Layer, InputSpec

我收到以下错误消息:

No module named 'tensorflow.keras.engine'

推荐答案

您可以从 TensorFlow 导入 LayerInputSpec 如下:

You can import Layer and InputSpec from TensorFlow as follows:

from tensorflow.python.keras.layers import Layer, InputSpec

更新:30/10/2019

from tensorflow.keras.layers import Layer, InputSpec

这篇关于如何在 Tensorflow 中导入 keras.engine.topology?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆