(images, splits=10, device=None)
return float(np.mean(scores)), float(np.std(scores))
Computes inception score according to official OpenAI implementation.

    Args:
        images (ndarray): Batch of images of shape (N, H, W, 3), which should have values
            in the range [0, 255].
        splits (int): Number of splits to use for computing IS.
        device (Device): Torch device object to decide which GPU to use for TF session.

    Returns:
        tuple: Tuple of mean and standard deviation of the inception score computed.
Computes inception score according to official OpenAI implementation.
Computes inception score according to official OpenAI implementation .
def get_inception_score(images, splits=10, device=None):
    """
    Computes inception score according to official OpenAI implementation.

    Args:
        images (ndarray): Batch of images of shape (N, H, W, 3), which should have values
            in the range [0, 255].
        splits (int): Number of splits to use for computing IS.
        device (Device): Torch device object to decide which GPU to use for TF session.

    Returns:
        tuple: Tuple of mean and standard deviation of the inception score computed.
    """
    if np.max(images[0] < 10) and np.max(images[0] < 0):
        raise ValueError("Images should have value ranging from 0 to 255.")

    # Load graph and get probabilities
    preds = get_predictions(images, device=device)

    # Compute scores
    N = preds.shape[0]
    scores = []
    for i in range(splits):
        part = preds[(i * N // splits):((i + 1) * N // splits), :]
        kl = part * (np.log(part) -
                     np.log(np.expand_dims(np.mean(part, 0), 0)))
        kl = np.mean(np.sum(kl, 1))
        scores.append(np.exp(kl))

    return float(np.mean(scores)), float(np.std(scores))
def get_inception_score ( images , splits = 10 , device = None ) : if np . max ( images [ 0 ] < 10 ) and np . max ( images [ 0 ] < 0 ) : raise ValueError ( "Images should have value ranging from 0 to 255." ) # Load graph and get probabilities preds = get_predictions ( images , device = device ) # Compute scores N = preds . shape [ 0 ] scores = [ ] for i in range ( splits ) : part = preds [ ( i * N // splits ) : ( ( i + 1 ) * N // splits ) , : ] kl = part * ( np . log ( part ) - np . log ( np . expand_dims ( np . mean ( part , 0 ) , 0 ) ) ) kl = np . mean ( np . sum ( kl , 1 ) ) scores . append ( np . exp ( kl ) ) return float ( np . mean ( scores ) ) , float ( np . std ( scores ) )