(dataset_name, num_samples=50000, **kwargs)
return images
Randomly sample num_samples images based on input dataset name.

    Args:
        dataset_name (str): Dataset name to load images from.
        num_samples (int): The number of images to randomly sample.

    Returns:
        Tensor: Batch of num_samples images from the specific dataset in np array form.
Randomly sample num_samples images based on input dataset name.
Randomly sample num_samples images based on input dataset name .
def get_dataset_images(dataset_name, num_samples=50000, **kwargs):
    """
    Randomly sample num_samples images based on input dataset name.

    Args:
        dataset_name (str): Dataset name to load images from.
        num_samples (int): The number of images to randomly sample.

    Returns:
        Tensor: Batch of num_samples images from the specific dataset in np array form.
    """
    if dataset_name == "cifar10":
        images = get_cifar10_images(num_samples, **kwargs)

    elif dataset_name == "cifar10_test":
        images = get_cifar10_images(num_samples, split='test', **kwargs)

    else:
        raise ValueError("Invalid dataset name {}.".format(dataset_name))

    # Check shape and permute if needed
    if images.shape[1] == 3:
        images = images.transpose((0, 2, 3, 1))

    # Ensure the values lie within the correct range, otherwise there might be some
    # preprocessing error from the library causing ill-valued scores.
    if np.min(images) < 0 or np.max(images) > 255:
        raise ValueError(
            'Image pixel values must lie between 0 to 255 inclusive.')

    return images
def get_dataset_images ( dataset_name , num_samples = 50000 , * * kwargs ) : if dataset_name == "cifar10" : images = get_cifar10_images ( num_samples , * * kwargs ) elif dataset_name == "cifar10_test" : images = get_cifar10_images ( num_samples , split = 'test' , * * kwargs ) else : raise ValueError ( "Invalid dataset name {}." . format ( dataset_name ) ) # Check shape and permute if needed if images . shape [ 1 ] == 3 : images = images . transpose ( ( 0 , 2 , 3 , 1 ) ) # Ensure the values lie within the correct range, otherwise there might be some # preprocessing error from the library causing ill-valued scores. if np . min ( images ) < 0 or np . max ( images ) > 255 : raise ValueError ( 'Image pixel values must lie between 0 to 255 inclusive.' ) return images