Keras中使用LSTM层时设置的units参数是什么
2018-01-13 21:11
239 查看
https://www.zhihu.com/question/64470274
http://colah.github.io/posts/2015-08-Understanding-LSTMs/ https://jasdeep06.github.io/posts/Understanding-LSTM-in-Tensorflow-MNIST/ https://stackoverflow.com/questions/37901047/what-is-num-units-in-tensorflow-basiclstmcell# http://keras-cn.readthedocs.io/en/latest/layers/recurrent_layer/
keras.layers.recurrent.LSTM(units, activation='tanh', recurrent_activation='hard_sigmoid', use_bias=True, kernel_initializer='glorot_uniform', recurrent_initializer='orthogonal', bias_initializer='zeros', unit_forget_bias=True, kernel_regularizer=None, recurrent_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, recurrent_constraint=None, bias_constraint=None, dropout=0.0, recurrent_dropout=0.0)
model = Sequential()
model.add(LSTM(32, return_sequences=True, stateful=True,batch_input_shape=(batch_size, timesteps, data_dim)))
model.add(LSTM(32, return_sequences=True, stateful=True))
model.add(LSTM(32, stateful=True))
model.add(Dense(num_classes, activation='softmax'))
类似上述代码中,加重黑色数字的含义。
下图是加了peephole的lstm,用来示例,lstm则需要去掉Ct-1和Ct项。可以看到LSTM里面有几个参数矩阵,Wf、Wi、Wo都是参数矩阵。我的理解,上面的数字32就是这个参数矩阵的组数。比如初始一组参数矩阵,Wf、Wi、Wo,计算一个lstm值,然后再给一组参数矩阵Wf1、Wi1、Wo1,可以再算一个lstm值,共32组。参考的博客里第一个也是类似的解释。
![](https://images2017.cnblogs.com/blog/65150/201801/65150-20180113210618847-140705296.png)
http://colah.github.io/posts/2015-08-Understanding-LSTMs/ https://jasdeep06.github.io/posts/Understanding-LSTM-in-Tensorflow-MNIST/ https://stackoverflow.com/questions/37901047/what-is-num-units-in-tensorflow-basiclstmcell# http://keras-cn.readthedocs.io/en/latest/layers/recurrent_layer/
keras.layers.recurrent.LSTM(units, activation='tanh', recurrent_activation='hard_sigmoid', use_bias=True, kernel_initializer='glorot_uniform', recurrent_initializer='orthogonal', bias_initializer='zeros', unit_forget_bias=True, kernel_regularizer=None, recurrent_regularizer=None, bias_regularizer=None, activity_regularizer=None, kernel_constraint=None, recurrent_constraint=None, bias_constraint=None, dropout=0.0, recurrent_dropout=0.0)
model = Sequential()
model.add(LSTM(32, return_sequences=True, stateful=True,batch_input_shape=(batch_size, timesteps, data_dim)))
model.add(LSTM(32, return_sequences=True, stateful=True))
model.add(LSTM(32, stateful=True))
model.add(Dense(num_classes, activation='softmax'))
类似上述代码中,加重黑色数字的含义。
下图是加了peephole的lstm,用来示例,lstm则需要去掉Ct-1和Ct项。可以看到LSTM里面有几个参数矩阵,Wf、Wi、Wo都是参数矩阵。我的理解,上面的数字32就是这个参数矩阵的组数。比如初始一组参数矩阵,Wf、Wi、Wo,计算一个lstm值,然后再给一组参数矩阵Wf1、Wi1、Wo1,可以再算一个lstm值,共32组。参考的博客里第一个也是类似的解释。
![](https://images2017.cnblogs.com/blog/65150/201801/65150-20180113210618847-140705296.png)
![](https://images2017.cnblogs.com/blog/65150/201801/65150-20180113211019129-1738064554.png)
相关文章推荐
- Keras关于LSTM的units参数,还是不理解?
- 在方法中使用ParamArray关键字来设置可变参数个数
- 测试工具Loadrunner日志参数的设置与使用 --http://epan-chen.javaeye.com/blog/317594
- 测试工具Loadrunner日志参数的设置与使用
- 使用SPA/GPA 参数--SAP内存参数设置&SET /GET PARAMTER ID
- IIS中永久重定向的使用(包括参数设置)-301
- C#中使用含参数的SQL语句一定要注意参数长度的设置
- questions_to_michael:使用http_load一般使用什么参数?关注结果的哪一部分?
- 使用Regex类设置url的参数
- App.xaml用途是什么?怎么传递参数和使用?
- 获取子窗口中使用jQuery.data()设置的参数置的参数
- IO模式设置网络编程常见问题总结—IO模式设置,阻塞与非阻塞的比较,recv参数对性能的影响—O_NONBLOCK(open使用)、IPC_NOWAIT(msgrcv)、MSG_DONTWAIT(re
- JavaScript使用cookie,参数设置,说明;读取,写入,删除函数
- IIS中永久重定向的使用(包括参数设置)
- [转]JavaScript使用cookie,参数设置,说明;读取,写入,删除函数
- 使用StartupInfo的参数设置窗口的启动位置的大小
- JavaScript使用cookie,参数设置,说明;读取,写入,删除函数
- 使用Office2003自带虚拟打印机的一些参数设置。
- JavaScript使用cookie,参数设置,说明;读取,写入,删除函数 【转】
- 系统参数中,设置“由平台收集后备案”是什么意思?