module 'tensorflow.python.keras.api._v2.keras.layers' has no attribute 'CuDNNLSTM'

≯℡__Kan透↙ 提交于 2020-03-21 14:23:37

问题


When I write tf.keras.layers.LSTM, I get the warning

Note that this layer is not optimized for performance. Please use tf.keras.layers.CuDNNLSTM for better performance on GPU.

But when I change the layer to tf.keras.layers.CuDNNLSTM, I get the error

AttributeError: module 'tensorflow.python.keras.api._v2.keras.layers' has no attribute 'CuDNNLSTM'

Tensorflow version is 2.0.0-alpha0, Keras version is 2.2.4-tf.

How can I fix this problem?


回答1:


In general, in TensorFlow 2.0 we should just use:

tf.keras.layers.LSTM

which, despite the warning, will use the GPU.

The warning message incorrectly existed in the 2.0.0-alpha0 version but has since been removed in 2.0.0-beta1

If for some reason you specifically need the original implementation of tf.keras.layers.CuDNNLSTM then you can use tf.compat.v1.keras.layers.CuDNNLSTM but this would be an edge case.



来源:https://stackoverflow.com/questions/55761337/module-tensorflow-python-keras-api-v2-keras-layers-has-no-attribute-cudnnlst

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!