本文介绍了Keras中的CuDNNLSTM和LSTM有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在高级深度学习库Keras中,存在多种类型的循环层;其中包括LSTM(长期短期记忆)和CuDNNLSTM.根据 Keras文档CuDNNLSTM是:

In Keras, the high-level deep learning library, there are multiple types of recurrent layers; these include LSTM (Long short term memory) and CuDNNLSTM. According to the Keras documentation, a CuDNNLSTM is a:

我相信Keras会尽可能自动使用GPU.根据 TensorFlow构建说明,要使TensorFlow GPU后端正常工作,您将需要CuDNN:

It is my belief that Keras automatically uses the GPU wherever possible. According to the TensorFlow build instructions, to have a working TensorFlow GPU backend, you will need CuDNN:

  • NVIDIA的Cuda工具包(> = 7.0).我们建议使用9.0版.有关详细信息,请参阅NVIDIA文档.确保按照NVIDIA文档中的说明将相关的Cuda路径名附加到LD_LIBRARY_PATH环境变量中.
  • 与NVIDIA Cuda Toolkit相关的NVIDIA驱动程序.
  • cuDNN (> = v3).我们建议使用6.0版.有关详细信息,请参阅NVIDIA文档,尤其是将适当的路径名附加到LD_LIBRARY_PATH环境变量的说明.
  • NVIDIA's Cuda Toolkit (>= 7.0). We recommend version 9.0. For details, see NVIDIA's documentation. Ensure that you append the relevant Cuda pathnames to the LD_LIBRARY_PATH environment variable as described in the NVIDIA documentation.
  • The NVIDIA drivers associated with NVIDIA's Cuda Toolkit.
  • cuDNN (>= v3). We recommend version 6.0. For details, see NVIDIA's documentation, particularly the description of appending the appropriate pathname to your LD_LIBRARY_PATH environment variable.

因此,使用TensorFlow GPU后端,CuDNNLSTM与普通LSTM有何不同?找到可用的TensorFlow GPU后端后,会自动选择CuDNNLSTM并替换普通的LSTM吗?

Therefore, how would a CuDNNLSTM differ in any way from a normal LSTM using a TensorFlow GPU backend? Will CuDNNLSTM be automatically selected and replace the normal LSTM when an available TensorFlow GPU backend is found?

推荐答案

您为什么不亲自尝试一下,看看呢?以我为例,用LSTM训练模型需要10分钟30秒.只需将通话从LSTM()切换到CuDNNLSTM(),就花费了不到一分钟的时间.

Why don't you try it out for yourself and see?In my case, training a model with LSTM took 10mins 30seconds.Simply switching the call from LSTM() to CuDNNLSTM() took less than a minute.

我还注意到,切换到CuDNNLSTM()也会大大提高model.evaluate()model.predict()的速度.

I also noticed that switching to CuDNNLSTM() speeds up model.evaluate() and model.predict() substantially as well.

这篇关于Keras中的CuDNNLSTM和LSTM有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-04 08:46