def namignizer_iterator(names, counts, batch_size, num_steps, epoch_size):
 name_distribution = (counts / counts.sum())
 for i in range(epoch_size):
  data = np.zeros(((batch_size * num_steps) + 1))
  samples = np.random.choice(names, size=((batch_size * num_steps) // 2), replace=True, p=name_distribution)
  data_index = 0
  for sample in samples:
   if (data_index >= (batch_size * num_steps)):
    break
   for letter in (map(_letter_to_number, sample) + [_EON]):
    if (data_index >= (batch_size * num_steps)):
     break
    data[data_index] = letter
    data_index += 1
  x = data[:(batch_size * num_steps)].reshape((batch_size, num_steps))
  y = data[1:((batch_size * num_steps) + 1)].reshape((batch_size, num_steps))
  (yield (x, y))

def namignizer_iterator ( names , counts , batch_size , num_steps , epoch_size ) : name_distribution = ( counts / counts . sum ( ) ) for i in range ( epoch_size ) : data = np . zeros ( ( ( batch_size * num_steps ) + 1 ) ) samples = np . random . choice ( names , size = ( ( batch_size * num_steps ) // 2 ) , replace = True , p = name_distribution ) data_index = 0 for sample in samples : if ( data_index >= ( batch_size * num_steps ) ) : break for letter in ( map ( _letter_to_number , sample ) + [ _EON ] ) : if ( data_index >= ( batch_size * num_steps ) ) : break data [ data_index ] = letter data_index += 1 x = data [ : ( batch_size * num_steps ) ] . reshape ( ( batch_size , num_steps ) ) y = data [ 1 : ( ( batch_size * num_steps ) + 1 ) ] . reshape ( ( batch_size , num_steps ) ) ( yield ( x , y ) )
takes a list of names and counts like those output from read_names .