def save_samples(generated_images, iteration, prefix):
    generated_images = generated_images.data.cpu().numpy()
    (num_images, channels, cell_h, cell_w) = generated_images.shape
    ncols = int(np.sqrt(num_images))
    nrows = int(np.math.floor((num_images / float(ncols))))
    result = np.zeros(((cell_h * nrows), (cell_w * ncols), channels), dtype=generated_images.dtype)
    for i in range(0, nrows):
        for j in range(0, ncols):
            result[(i * cell_h):((i + 1) * cell_h), (j * cell_w):((j + 1) * cell_w), :] = generated_images[((i * ncols) + j)].transpose(1, 2, 0)
    grid = result
    if (not os.path.exists('output')):
        os.makedirs('output')
    scipy.misc.imsave('output/{}_{:05d}.jpg'.format(prefix, iteration), grid)
def save_samples(generated_images, iteration, prefix):
    generated_images = generated_images.data.cpu().numpy()
    (num_images, channels, cell_h, cell_w) = generated_images.shape
    ncols = int(np.sqrt(num_images))
    nrows = int(np.math.floor((num_images / float(ncols))))
    result = np.zeros(((cell_h * nrows), (cell_w * ncols), channels), dtype=generated_images.dtype)
    for i in range(0, nrows):
        for j in range(0, ncols):
            result[(i * cell_h):((i + 1) * cell_h), (j * cell_w):((j + 1) * cell_w), :] = generated_images[((i * ncols) + j)].transpose(1, 2, 0)
    grid = result
    if (not os.path.exists('output')):
        os.makedirs('output')
    scipy.misc.imsave('output/{}_{:05d}.jpg'.format(prefix, iteration), grid)