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
评论列表
文章目录