The CuDNNGRU
in TensorFlow 1.0
真的很快。但当我转向TensorFlow 2.0
我找不到CuDNNGRU
。简单的GRU
真的很慢TensorFlow 2.0
.
有什么办法可以使用吗CuDNNGRU
in TensorFlow 2.0
?
可导入的实现已被弃用 - 相反,LSTM
and GRU
将默认为CuDNNLSTM
and CuDNNGRU
if all 满足条件 https://github.com/tensorflow/tensorflow/blob/r2.1/tensorflow/python/keras/layers/recurrent_v2.py#L902:
activation = 'tanh'
recurrent_activation = 'sigmoid'
recurrent_dropout = 0
unroll = False
use_bias = True
- Inputs, 如果蒙面, 严格右填充
-
reset_after = True
(仅限 GRU)
还要确保 TensorFlow 使用 GPU:
import tensorflow as tf
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
Update:在 Colab 上运行时,TF 2.0.0 似乎无法让 CuDNN 正常工作;尝试!pip install tensorflow==2.1.0
反而。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)