Exemplo n.º 1
0
def categorical_crossentropy(expected, predicted):
    """
    Categorical cross-entropy error.

    Parameters
    ----------
    {error_function.expected}
    {error_function.predicted}

    Returns
    -------
    {error_function.Returns}
    """
    epsilon = smallest_positive_number()
    predicted = T.clip(predicted, epsilon, 1.0 - epsilon)
    return T.nnet.categorical_crossentropy(predicted, expected).mean()
Exemplo n.º 2
0
def categorical_crossentropy(expected, predicted):
    """
    Categorical cross-entropy error.

    Parameters
    ----------
    {error_function.expected}
    {error_function.predicted}

    Returns
    -------
    {error_function.Returns}
    """
    epsilon = smallest_positive_number()
    predicted = T.clip(predicted, epsilon, 1.0 - epsilon)
    return T.nnet.categorical_crossentropy(predicted, expected).mean()
Exemplo n.º 3
0
 def test_smallest_positive_number(self):
     epsilon = smallest_positive_number()
     self.assertNotEqual(0, asfloat(1) - (asfloat(1) - asfloat(epsilon)))
     self.assertEqual(0, asfloat(1) - (asfloat(1) - asfloat(epsilon / 10)))
Exemplo n.º 4
0
def categorical_crossentropy(expected, predicted):
    """ Categorical cross-entropy error.
    """
    epsilon = smallest_positive_number()
    predicted = T.clip(predicted, epsilon, 1.0 - epsilon)
    return T.nnet.categorical_crossentropy(predicted, expected).mean()
Exemplo n.º 5
0
def binary_crossentropy(expected, predicted):
    """ Binary cross-entropy error.
    """
    epsilon = smallest_positive_number()
    predicted = T.clip(predicted, epsilon, 1.0 - epsilon)
    return T.nnet.binary_crossentropy(predicted, expected).mean()
Exemplo n.º 6
0
 def test_smallest_positive_number(self):
     epsilon = smallest_positive_number()
     self.assertNotEqual(0, asfloat(1) - (asfloat(1) - asfloat(epsilon)))
     self.assertEqual(0, asfloat(1) - (asfloat(1) - asfloat(epsilon / 10)))
Exemplo n.º 7
0
def categorical_crossentropy(expected, predicted):
    """ Categorical cross-entropy error.
    """
    epsilon = smallest_positive_number()
    predicted = T.clip(predicted, epsilon, 1.0 - epsilon)
    return T.nnet.categorical_crossentropy(predicted, expected).mean()
Exemplo n.º 8
0
def binary_crossentropy(expected, predicted):
    """ Binary cross-entropy error.
    """
    epsilon = smallest_positive_number()
    predicted = T.clip(predicted, epsilon, 1.0 - epsilon)
    return T.nnet.binary_crossentropy(predicted, expected).mean()