首页 > 解决方案 > 使用 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 单元的数量,但没有成功。鉴于每个声音的旋律线彼此之间存在关系(持续时间也是如此),这是正确的架构吗?我应该增加更多的细胞数量吗?

为了更清楚一点,假设我的目标是“过度拟合”输入数据,所以理论上网络应该收敛到一个小的损失值,但这并没有发生。

感谢您的帮助,如果需要,我可以提供更多详细信息。

标签: pythontensorflowkerasdeep-learninglstm

解决方案


推荐阅读