Keras CuDNNLSTM隐式激活函数? [英] Keras CuDNNLSTM implicit activation function?
问题描述
在activation
参数(默认为tanh
)
CuDNNLSTM 没有任何内容,但具有activity_regularizer
参数.
我想念什么吗?
CuDNNLSTM不是tf.keras.layers.LSTM包装器,而是独立的实体,那么如何为它设置激活功能?
While in tf.keras.layers.LSTM there is an activation
parameter (default tanh
)
the CuDNNLSTM doesn't have any, while having a activity_regularizer
parameter.
Am I missing something?
CuDNNLSTM is not a tf.keras.layers.LSTM wrapper, but a standalone entity, so how do I set the activation function for it?
推荐答案
CuDNNLSTM具有硬编码的tanh激活.据我所知,这是无法更改的.如果需要其他激活,则可以使用常规LSTM层.
CuDNNLSTM has a hardcoded tanh activation. As far as I am aware, there is no way for this to be changed. If you need some other activation, you're stuck using a regular LSTM layer.
或者,如果您只需要为模型激活特定的输出,例如softmax,您可以粘贴在Dense层上,然后再进行激活.这是我针对特定情况的操作方式的摘要:
Alternately, if you only need a specific output activation for your model, e.g. softmax, you can stick on a Dense layer and then put the activation after that. Here's a snippet of how I'm doing that for my particular case:
x = CuDNNLSTM(256, return_sequences=True)(x)
x = TimeDistributed(Dense(8))(x)
x = Softmax(axis=2)(x)
进一步阅读:
- https://github.com/keras-team/keras/issues/8510
- https://devblogs.nvidia.com/optimizing- recurrent-neural-networks-cudnn-5/
- https://github.com/keras-team/keras/issues/8510
- https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/
这篇关于Keras CuDNNLSTM隐式激活函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!