(
    probabilities_graph, probabilities_distance, EPS=1e-4, repulsion_strength=1.0
)
return attraction_term, repellant_term, CE
Compute cross entropy between low and high probability

    Parameters
    ----------
    probabilities_graph : array
        high dimensional probabilities
    probabilities_distance : array
        low dimensional probabilities
    EPS : float, optional
        offset to to ensure log is taken of a positive number, by default 1e-4
    repulsion_strength : float, optional
        strength of repulsion between negative samples, by default 1.0

    Returns
    -------
    attraction_term: tf.float32
        attraction term for cross entropy loss
    repellant_term: tf.float32
        repellant term for cross entropy loss
    cross_entropy: tf.float32
        cross entropy umap loss
Compute cross entropy between low and high probability
Compute cross entropy between low and high probability
def compute_cross_entropy(
    probabilities_graph, probabilities_distance, EPS=1e-4, repulsion_strength=1.0
):
    """
    Compute cross entropy between low and high probability

    Parameters
    ----------
    probabilities_graph : array
        high dimensional probabilities
    probabilities_distance : array
        low dimensional probabilities
    EPS : float, optional
        offset to to ensure log is taken of a positive number, by default 1e-4
    repulsion_strength : float, optional
        strength of repulsion between negative samples, by default 1.0

    Returns
    -------
    attraction_term: tf.float32
        attraction term for cross entropy loss
    repellant_term: tf.float32
        repellant term for cross entropy loss
    cross_entropy: tf.float32
        cross entropy umap loss

    """
    # cross entropy
    attraction_term = -probabilities_graph * tf.math.log(
        tf.clip_by_value(probabilities_distance, EPS, 1.0)
    )
    repellant_term = (
        -(1.0 - probabilities_graph)
        * tf.math.log(tf.clip_by_value(1.0 - probabilities_distance, EPS, 1.0))
        * repulsion_strength
    )

    # balance the expected losses between atrraction and repel
    CE = attraction_term + repellant_term
    return attraction_term, repellant_term, CE
def compute_cross_entropy ( probabilities_graph , probabilities_distance , EPS = 1e-4 , repulsion_strength = 1.0 ) : # cross entropy attraction_term = - probabilities_graph * tf . math . log ( tf . clip_by_value ( probabilities_distance , EPS , 1.0 ) ) repellant_term = ( - ( 1.0 - probabilities_graph ) * tf . math . log ( tf . clip_by_value ( 1.0 - probabilities_distance , EPS , 1.0 ) ) * repulsion_strength ) # balance the expected losses between atrraction and repel CE = attraction_term + repellant_term return attraction_term , repellant_term , CE