def get_batch(vectorized_songs, seq_length, batch_size): # the length of the vectorized songs string n = vectorized_songs.shape[0] - 1 # randomly choose the starting indices for the examples in the training batch idx = np.random.choice(n-seq_length, batch_size) '''TODO: construct a list of input sequences for the training batch''' input_batch = [vectorized_songs[i:i+seq_length] for i in idx]# TODO '''TODO: construct a list of output sequences for the training batch''' output_batch = [vectorized_songs[i+1:i+seq_length+1] for i in idx] # TODO # x_batch, y_batch provide the true inputs and targets for network training # print(input_batch, output_batch) x_batch = np.reshape(input_batch, [batch_size, seq_length]) y_batch = np.reshape(output_batch, [batch_size, seq_length]) return x_batch, y_batch
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter