【Tensorflow+keras】解决 Fail to find the dnn implementation.
解决 to The Tensorflow Find Keras fail implementation
2023-09-14 09:12:40 时间
1 引言
(1)环境
Tensorflow 2.0
Python 3.6
(2)问题
from tensorflow.keras import *
from tensorflow.keras.layers import Bidirectional,LSTM
在使用Bidirectional(LSTM )时,报错 [Derived] Fail to find the dnn implementation.
2 解决
因为在Tensorflow2.0中使用keras的API时,该版本的keras已经不支持直接使用Bidirectional(LSTM ),三种解决办法。
(1)第一种方法
继续使用在Tensorflow2.0的keras API,用兼容的替代的写法
from tensorflow.keras import *
from tensorflow.keras.layers import Bidirectional
Bidirectional(tf.keras.layers.RNN(tf.keras.layers.LSTMCell(n_BiLSTM_1),return_sequences=True))
(2)第二种方法
使用支持该方法的原装Keras:2.1.6
# 安装
pip install keras ==2.1.6
# 使用
from keras.layers import Bidirectional,LSTM
(3)第三种方法
继续使用在Tensorflow2.0的keras API,但加入表示兼容的代码
from tensorflow.keras.layers import Bidirectional,LSTM
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession
config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)
相关文章
- "undefined reference to" 问题解决方法
- 解决: Got permission denied while trying to connect to the Docker daemon socket
- 宇视摄像机/NVR OCX插件插件安装出现:Failed to register ocx, error code 14001 错误的解决方法
- git push报错 fatal: The current branch master has no upstream branch. To push the current
- 成功解决ValueError: Parameter values for parameter (max_depth) need to be a sequence.
- 成功解决The following specifications were found to be incompatible with the existing python installation
- 成功解决Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2(二)
- 已解决To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags
- 已解决ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: ‘e:anacondainstall_r
- 已解决The method is not allowed for the requested URL.
- 已解决Resource punkt not found. Please use the NLTK Downloader to obtain the resource:
- 已解决SQL_ERROR_INFO: “You have an error in your SQL syntax; check the manual that corresponds to your
- 【K3s】第25篇 解决The connection to the server localhost:8080 was refused
- xxx cannot be resolved to a type 错误解决方法
- 解决 - java.lang.OutOfMemoryError: unable to create new native thread
- 【问题解决】The connection to the server localhost:8080 was refused
- Error:The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location:
- 运行bee run之后出现的错误以及解决方法Failed to build the application:
- 【Tensorflow 2】解决tensorflow.python.framework.errors_impl.UnknownError: [_Derived_] Fail to find the
- 解决运行js代码报错—Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs
- 【openEuler】解决 Error: Failed to download metadata for repo ‘OS‘: Cannot download repomd.xml
- 解决 Using platform encoding (UTF-8 actually) to copy filtered resources 错误现象
- K8S 证书过期,报错:Unable to connect to the server: x509: certificate has expired or is not yet valid 解决方法