def modelConstruction(self):
"""
Construct the melody and rhythm model.
"""
# self.melody.add(GRU(128, consume_less = 'mem', return_sequences = True,
# input_shape = (self.timestep, 56)))
# # self.melody.add(Dropout(0.5))
# self.rhythm.add(GRU(128, consume_less = 'mem', return_sequences = True,
# input_shape = (self.timestep, 56)))
# self.rhythm.add(Dropout(0.5))
#
# for i in range(2):
# self.melody.add(GRU(128, return_sequences = True))
# # self.melody.add(Dropout(0.5))
# self.rhythm.add(GRU(128, return_sequences = True))
# self.rhythm.add(Dropout(0.5))
self.melody.add(Dense(128, input_shape = (self.timestep, 56)))
self.rhythm.add(Dense(128, input_shape = (self.timestep, 56)))
for i in range(4):
self.melody.add(Bidirectional(LSTM(128, return_sequences = True)))
self.melody.add(Dropout(0.5))
self.rhythm.add(GRU(128, return_sequences = True))
# self.rhythm.add(Dropout(0.5))
self.melody.add(Dense(128, input_shape = (self.timestep, 56)))
self.rhythm.add(Dense(128, input_shape = (self.timestep, 56)))
# for i in range(3):
# self.melody.add(Bidirectional(GRU(128, return_sequences = True)))
# self.melody.add(Dropout(0.5))
# self.rhythm.add(GRU(128, return_sequences = True))
self.melody.add(Dense(33, activation = 'softmax'))
self.rhythm.add(Dense(23, activation = 'softmax'))
#compile part
self.melody.compile(optimizer = 'adam',
#loss = self.my_loss_function()
loss = 'categorical_crossentropy')
self.rhythm.compile(optimizer = 'adam',
#loss = self.my_loss_function()
loss = 'categorical_crossentropy')
评论列表
文章目录