(x, y, batch_size=64, shuffle=True)
Generates a batch iterator for a dataset.
Generates a batch iterator for a dataset.
Generates a batch iterator for a dataset .
def batch_iter(x, y, batch_size=64, shuffle=True):
    """
    Generates a batch iterator for a dataset.
    """
    data_len = len(x)
    num_batch = int((data_len - 1) / batch_size) + 1

    # Shuffle the data at each epoch
    if shuffle:
        shuffle_indices = np.random.permutation(np.arange(data_len))
        x_shuffle = x[shuffle_indices]
        y_shuffle = y[shuffle_indices]
    else:
        x_shuffle = x
        y_shuffle = y
    for i in range(num_batch):
        start_index = i * batch_size
        end_index = min((i + 1) * batch_size, data_len)
        yield (x_shuffle[start_index:end_index], y_shuffle[start_index:end_index])
def batch_iter ( x , y , batch_size = 64 , shuffle = True ) : data_len = len ( x ) num_batch = int ( ( data_len - 1 ) / batch_size ) + 1 # Shuffle the data at each epoch if shuffle : shuffle_indices = np . random . permutation ( np . arange ( data_len ) ) x_shuffle = x [ shuffle_indices ] y_shuffle = y [ shuffle_indices ] else : x_shuffle = x y_shuffle = y for i in range ( num_batch ) : start_index = i * batch_size end_index = min ( ( i + 1 ) * batch_size , data_len ) yield ( x_shuffle [ start_index : end_index ] , y_shuffle [ start_index : end_index ] )