【483】Keras 中 LSTM 与 BiLSTM 语法
LSTM(units=32, input_shape=(10, 64))
- units=32:输出神经元个数
- input_shape=(10, 64):输入数据形状,10 代表时间序列的长度,64 代表每个时间序列数据的维度
LSTM(units=32, input_dim=64, input_length=10)
- units=32:输出神经元个数
- input_dim=64:每个时间序列数据的维度
- input_length=10:时间序列的长度
☀☀☀<< 举例 >>☀☀☀
1 2 3 4 5 6 7 8 9 10 11 12 | # as the first layer in a Sequential model model = Sequential() model.add(LSTM( 32 , input_shape = ( 10 , 64 ))) # now model.output_shape == (None, 10, 32) # note: `None` is the batch dimension. # the following is identical: model = Sequential() model.add(LSTM( 32 , input_dim = 64 , input_length = 10 )) # for subsequent layers, not need to specify the input size: model.add(LSTM( 16 )) |
- return_sequences:布尔值,默认False,控制返回类型。若为True则返回整个序列,否则仅返回输出序列的最后一个输出
keras.layers.wrappers.Bidirectional(layer, merge_mode='concat', weights=None)
双向RNN包装器
参数
- layer:Recurrent对象
- merge_mode:前向和后向RNN输出的结合方式,为sum,mul,concat,ave和None之一,若设为None,则返回值不结合,而是以列表的形式返回
☀☀☀<< 举例 >>☀☀☀
1 2 3 4 5 6 | model = Sequential() model.add(Bidirectional(LSTM( 10 , return_sequences = True ), input_shape = ( 5 , 10 ))) model.add(Bidirectional(LSTM( 10 ))) model.add(Dense( 5 )) model.add(Activation( 'softmax' )) model. compile (loss = 'categorical_crossentropy' , optimizer = 'rmsprop' ) |
分类:
AI Related
posted on 2020-09-24 23:55 McDelfino 阅读(2771) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2019-09-24 【439】Tweets processing by Python