src/main/java/convnet/NumPute.java
/**
     * Cross entropy function for calculating loss.
     * @param x
     * @param y
     */
Cross entropy function for calculating loss.
@param x
@param y
Cross entropy function for calculating loss . @param x @param y
public static double crossEntropy(double[] x, int[] y) {
        double acc = 0.0;
        for (int i = 0; i < y.length; i++) {
            if (x[i] != 0) {
                acc += (y[i] * Math.log(x[i]));
            }
        }
        double loss = -acc;
        return loss;
    }
public static double crossEntropy ( double [ ] x , int [ ] y ) { double acc = 0.0 ; for ( int i = 0 ; i < y . length ; i ++ ) { if ( x [ i ] != 0 ) { acc += ( y [ i ] * Math . log ( x [ i ] ) ) ; } } double loss = - acc ; return loss ; }
Cross entropy function for calculating loss.
Cross entropy function for calculating loss .