python - 使用 LSTM 生成音乐 - 损失停止减少
问题描述
我正在使用 LSTM 生成巴赫风格的作品。到目前为止,我仅使用单个声音的旋律序列就取得了成功,即,我能够为每个音符生成具有固定持续时间的单个旋律线。
现在,我正在尝试对一些巴赫合唱中的四种声音以及音符持续时间进行建模(参见http://www.bachcentral.com/midiindexcomplete.html底部的“合唱”midis )。
问题是,在某些时候,我的 LSTM 停止了学习。这是我的架构:
对于每个声音,我提取一系列 L 音符作为输入,下一个音符作为输出。然后我对笔记持续时间做同样的事情。所以我有:
voice0_x = sequence of notes, sequence of duration
voice0_y = next note, next duration
voice1_x = ... the same
voice1_y = ... the same
然后 nnet 代码如下:
input_notes = Input(shape=(notes_in.shape[1], notes_in.shape[2]))
note_out = LSTM(256, return_sequences=True)(input_notes)
input_durations = Input(shape=(durations_in.shape[1], durations_in.shape[2]))
duration_out = LSTM(256, return_sequences=True)(input_durations)
merge = concatenate([note_out, duration_out])
merge = Flatten()(merge)
merge = Dense(512, activation='relu')(merge)
merge = Dropout(0.3)(merge)
note_final = Dense(notes_out.shape[1], activation='softmax')(merge)
duration_final = Dense(durations_out.shape[1], activation='softmax')(merge)
model = Model(inputs=[input_notes, input_durations], outputs=[note_final, duration_final])
model.compile(loss=['categorical_crossentropy', 'categorical_crossentropy'], optimizer = 'rmsprop')
所以,我只是将音符和持续时间序列提供给分离 LSTM,连接它们的输出并将所有内容发送到密集层。网络显然在学习,但损失在 ~12.35 时停止下降:
loss: 12.3549 - dense_2_loss: 6.3240 dense_3_loss: 6.0309
我尝试增加 LSTM 单元的数量,但没有成功。鉴于每个声音的旋律线彼此之间存在关系(持续时间也是如此),这是正确的架构吗?我应该增加更多的细胞数量吗?
为了更清楚一点,假设我的目标是“过度拟合”输入数据,所以理论上网络应该收敛到一个小的损失值,但这并没有发生。
感谢您的帮助,如果需要,我可以提供更多详细信息。
解决方案
推荐阅读
- git - gitlab-ci - 有 2 个分支的仓库,2 个 gitlab-ci
- r - How to include a second axis in ggplot with another dataframe?
- javascript - 如何在不重新加载整个页面的情况下使用 django 在网站上显示数据
- postgresql - postgres 的 sql 类型(映射)无效
- python - Python 3.x,矩阵不能按预期工作
- python - 如何将具有不同数量数据点的 2 个数据集缩放到一个图表中?
- database - PostgreSQL:汉字存储为问号
- c# - C# 中的 LINQ 获取员工的签入和签出时间
- python - 如何接受用户输入进行预测 scikitlearn
- postgresql - spring boot,flyway - 如何编写独立于方言(jdbc)的 sql 查询?