nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/loss/LossFunctions.java
public static LossInfo mcxent(String outputName, SDVariable predictions, SDVariable label, SDVariable weights,
                                  Reduction reduction, int... dimensions){
        LossInfo.Builder b = validate("mcxent", predictions, label, reduction);
        SameDiff sd = predictions.getSameDiff();

        if(weights == null){
            weights = sd.one("mcxent_loss_weights", SCALAR);
        }

        String name = (reduction == Reduction.NONE ? outputName : null);
        SDVariable weightedLogProd = sd.log(predictions).mul(label).mul(name, weights);

        return doReduce(sd, outputName, false, b, reduction, weightedLogProd, label, weights, dimensions);
    }
public static LossInfo mcxent(String outputName, SDVariable predictions, SDVariable label, SDVariable weights,
                                  Reduction reduction, int... dimensions){
        LossInfo.Builder b = validate("mcxent", predictions, label, reduction);
        SameDiff sd = predictions.getSameDiff();

        if(weights == null){
            weights = sd.one("mcxent_loss_weights", SCALAR);
        }

        String name = (reduction == Reduction.NONE ? outputName : null);
        SDVariable weightedLogProd = sd.log(predictions).mul(label).mul(name, weights);

        return doReduce(sd, outputName, false, b, reduction, weightedLogProd, label, weights, dimensions);
    }
public static LossInfo mcxent ( String outputName , SDVariable predictions , SDVariable label , SDVariable weights , Reduction reduction , int ... dimensions ) { LossInfo . Builder b = validate ( "mcxent" , predictions , label , reduction ) ; SameDiff sd = predictions . getSameDiff ( ) ; if ( weights == null ) { weights = sd . one ( "mcxent_loss_weights" , SCALAR ) ; } String name = ( reduction == Reduction . NONE ? outputName : null ) ; SDVariable weightedLogProd = sd . log ( predictions ) . mul ( label ) . mul ( name , weights ) ; return doReduce ( sd , outputName , false , b , reduction , weightedLogProd , label , weights , dimensions ) ; }
Multi-Class Cross Entropy loss function:<br>
L = sum_i actual_i * log( predicted_i )

@param outputName
@param predictions
@param label
@param weights
@param reduction
@param dimensions
@return
Multi - Class Cross Entropy loss function : <br > L = sum_i actual_i * log ( predicted_i )