data_reader.py 文件源码

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

项目:encore.ai 作者: dyelax 项目源码 文件源码
def get_seq(self, seq_len):
        """
        Gets a single pair of sequences (input, target) from a random song.

        @param seq_len: The number of words in a sequence.

        @return: A tuple of sequences, (input, target) offset from each other by one word.
        """
        # Pick a random song. Must be longer than seq_len
        for i in xrange(1000):  # cap at 1000 tries
            song = random.choice(self.lyric_indices)
            if len(song) > seq_len: break

        # Take a sequence of (seq_len) from the song lyrics
        i = random.randint(0, len(song) - (seq_len + 1))
        inp= np.array(song[i:i+seq_len], dtype=int)
        target =  np.array(song[i+1:i+seq_len+1], dtype=int)
        return inp, target
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号