Snippets Collections
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
star

Thu Mar 04 2021 11:47:16 GMT+0000 (UTC) https://colab.research.google.com/drive/1k9L_FQgvOs_Nd-DCyAgrqCaKBK3rNJIo#scrollTo=LF-N8F7BoDRi

#tensorflow #python

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension