melodyGenerater.py 文件源码

python
阅读 12 收藏 0 点赞 0 评论 0

项目:DNN-Composer 作者: ChyauAng 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号