python - 模块 'tensorflow.python.keras.api._v2.keras.layers' 没有属性 'CuDNNLSTM'

标签 python tensorflow keras deep-learning

当我编写 tf.keras.layers.LSTM 时,我收到了警告

请注意,该层并未针对性能进行优化。请使用 tf.keras.layers.CuDNNLSTM 以获得更好的 GPU 性能。

但是当我将图层更改为 tf.keras.layers.CuDNNLSTM 时,出现错误

AttributeError: 模块 'tensorflow.python.keras.api._v2.keras.layers' 没有属性 'CuDNNLSTM'

Tensorflow 版本为 2.0.0-alpha0,Keras 版本为 2.2.4-tf。

我该如何解决这个问题?

最佳答案

一般来说,在 TensorFlow 2.0 中我们应该只使用:

tf.keras.layers.LSTM

尽管有警告,使用 GPU。

警告消息错误地存在于 2.0.0-alpha0 版本中,但已在 2.0.0-beta1 中删除

如果出于某种原因您特别需要 tf.keras.layers.CuDNNLSTM 的原始实现,那么您可以使用 tf.compat.v1.keras.layers.CuDNNLSTM但这将是一个边缘案例。

关于python - 模块 'tensorflow.python.keras.api._v2.keras.layers' 没有属性 'CuDNNLSTM',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55761337/

相关文章:

python - 无法使用 ResNet50 在 Keras 中加载权重以进行微调

neural-network - 子梯度的总和或平均值?,小批量 SGD keras

python - 首先使用 Keras 进行 channel ?

Keras:使用铰链或分类铰链实现 SVM?

python - 使用 Kubeflow 保存模型工件而不使用 Pipeline

Python UTF-16 WAVY DASH 编码问题/问题

python - 在 py2neo 中添加标签不起作用

python - 值错误 : Could not find matching function to call loaded from the SavedModel

python - 为什么它保留在列表中?

python - tensorflow 集线器 : module spec export with checkpoint path doesn't save all variables