lstm.py 文件源码

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

项目:harmonizer 作者: meagtan 项目源码 文件源码
def getnotes(self, voice = None):
        # global mat
        if voice is None:
            return [self.getnotes(v) for v in xrange(len(self.s.parts))]
        if self.notes[voice] is None:
            endtimes = self.s.flat.notesAndRests.stream()._uniqueOffsetsAndEndTimes(endTimesOnly=True)
            self.notes[voice] = [None] * len(endtimes)
            notes = list(self.s.parts[voice].flat.notesAndRests)
            j = 0 # index of current note
            curr = 0.0
            for i in xrange(len(endtimes)):
                self.notes[voice][i] = map(lambda k: (isinstance(notes[j], note.Note) and \
                                           k == pitchtoid(notes[j].pitch, self.key)) * \
                                           (endtimes[i] - curr), range(Din))
                # if current note ends here, go to next note
                if endtimes[i] == notes[j].offset + notes[j].quarterLength:
                    j += 1
                curr = endtimes[i]
            self.notes[voice] = torch.FloatTensor(self.notes[voice])
            n = self.notes[voice].clone().apply_(lambda n: int(n != 0))
            # mat += n[:-1].t().mm(n[1:])
        return self.notes[voice]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号