tensorflow - cuDNN 内核上的 LSTM 配置
问题描述
我正在尝试在具有 gpu 支持的 Google Colab 中使用自动编码器配置运行 LSTM。但我收到以下警告:
警告:tensorflow:Layer lstm 不会使用 cuDNN 内核,因为它不符合 cuDNN 内核标准。在 GPU 上运行时,它将使用通用 GPU 内核作为后备
通用 GPU 内核比 cuDNN 内核慢得多。所以我搜索了解决方案,并在此处找到(https://keras.io/api/layers/recurrent_layers/lstm/)LSTM单元的 cuDNN 内核要求。具体来说:
activation == tanh
recurrent_activation == sigmoid
recurrent_dropout == 0
unroll is False
use_bias is True
Inputs, if use masking, are strictly right-padded.
Eager execution is enabled in the outermost context.
我以为我在激活函数中发现了问题,即“relu”,其他 cuDNN 要求是 TF 中的默认值。这是更新的代码:
model = Sequential()
model.add(LSTM(200, activation='tanh',input_shape=(n_timesteps, n_features)))
model.add(RepeatVector(n_outputs))
model.add(LSTM(200, activation='tanh', return_sequences=True))
model.add(TimeDistributed(Dense(100, activation='relu')))
model.add(TimeDistributed(Dense(1)))
model.compile(loss='mse', optimizer='adam')
model.fit(train_x, train_y, epochs=epochs, batch_size=batch_size, verbose=verbose)
但是在执行时,我会收到相同的警告,即未满足 cuDNN 要求。怎么了?
TF:2.3.0
解决方案
推荐阅读
- plsql - 编译以下代码时出现 PLSQL 错误 - PLS-00103
- python - 在 python virtualenv 中安装旧版本的依赖项并收到错误:没有为 tiledtmxloader==3.1.0 找到匹配的发行版
- winapi - 使用 Win32 应用程序(Flutter Desktop)的“发送到”快捷方式获取文件的路径
- javascript - Canvas npm 包 v2.8.0 图像在尝试 drawImage 时像素化,如何解决?
- python-3.x - 如何在 Ubuntu 上的 python 3 中添加证书验证
- flutter - Flutter:如何上传和预览 PDF
- php - 请帮助,in_array() 期望参数 2 是数组
- unity3d - 实例化和随机四元数
- d3.js - D3.js 层次结构按字段计算汇总
- c# - 如何检查剃刀视图是否存在,但在 ASP.NET Core Razor 页面中?