[英]module 'tensorflow.python.keras.api._v2.keras.layers' has no attribute 'CuDNNLSTM'
When I write tf.keras.layers.LSTM
, I get the warning当我写tf.keras.layers.LSTM
时,我收到警告
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但是当我将层更改为tf.keras.layers.CuDNNLSTM
时,出现错误
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. Tensorflow 版本为 2.0.0-alpha0,Keras 版本为 2.2.4-tf。
How can I fix this problem?我该如何解决这个问题?
In general, in TensorFlow 2.0 we should just use:一般来说,在 TensorFlow 2.0 中我们应该只使用:
tf.keras.layers.LSTM
which, despite the warning, will use the GPU.尽管有警告,它仍将使用 GPU。
The warning message incorrectly existed in the 2.0.0-alpha0
version but has since been removed in 2.0.0-beta1
该警告消息错误地存在于2.0.0-alpha0
版本中,但已在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.如果出于某种原因您特别需要tf.keras.layers.CuDNNLSTM
的原始实现,那么您可以使用tf.compat.v1.keras.layers.CuDNNLSTM
但这将是一种边缘情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.