张量流2.0中是否有cudnnLSTM或cudNNGRU替代方案

2023-12-25

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:

  1. activation = 'tanh'
  2. recurrent_activation = 'sigmoid'
  3. recurrent_dropout = 0
  4. unroll = False
  5. use_bias = True
  6. Inputs, 如果蒙面, 严格右填充
  7. 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(使用前将#替换为@)

张量流2.0中是否有cudnnLSTM或cudNNGRU替代方案 的相关文章

随机推荐