模块'tensorflow.python.keras.api._v2.keras.layers'没有属性'CuDNNLSTM' [英] module 'tensorflow.python.keras.api._v2.keras.layers' has no attribute 'CuDNNLSTM'

查看:1530
本文介绍了模块'tensorflow.python.keras.api._v2.keras.layers'没有属性'CuDNNLSTM'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我写tf.keras.layers.LSTM时,我得到警告

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

但是当我将图层更改为tf.keras.layers.CuDNNLSTM时,我得到了错误

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版本为2.0.0-alpha0,Keras版本为2.2.4-tf.

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

如何解决此问题?

推荐答案

通常,在TensorFlow 2.0中,我们应该使用:

In general, in TensorFlow 2.0 we should just use:

tf.keras.layers.LSTM

尽管有警告,但使用GPU.

which, despite the warning, will use the GPU.

警告消息在2.0.0-alpha0版本中不正确地存在,但是在2.0.0-beta1

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

如果由于某些原因您特别需要tf.keras.layers.CuDNNLSTM的原始实现,则可以使用tf.compat.v1.keras.layers.CuDNNLSTM,但这是一个极端的情况.

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.

这篇关于模块'tensorflow.python.keras.api._v2.keras.layers'没有属性'CuDNNLSTM'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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