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

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

        SDVariable diff = predictions.sub(label);
        String name = (reduction == Reduction.NONE ? outputName : null);
        SDVariable preReduceLoss = sd.square(diff).mul(name, weights);

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

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

        SDVariable diff = predictions.sub(label);
        String name = (reduction == Reduction.NONE ? outputName : null);
        SDVariable preReduceLoss = sd.square(diff).mul(name, weights);

        return doReduce(sd, outputName, true, b, reduction, preReduceLoss, label, weights, dimensions);
    }
public static LossInfo mse ( String outputName , SDVariable predictions , SDVariable label , SDVariable weights , Reduction reduction , int ... dimensions ) { LossInfo . Builder b = validate ( "mse" , predictions , label , reduction ) ; SameDiff sd = predictions . getSameDiff ( ) ; if ( weights == null ) { weights = sd . one ( "mse_loss_weights" , SCALAR ) ; } SDVariable diff = predictions . sub ( label ) ; String name = ( reduction == Reduction . NONE ? outputName : null ) ; SDVariable preReduceLoss = sd . square ( diff ) . mul ( name , weights ) ; return doReduce ( sd , outputName , true , b , reduction , preReduceLoss , label , weights , dimensions ) ; }
Mean squared error: L = mean( (predicted - label)^2)

@param outputName  Name of the output SDVariable
@param predictions Predictions variable
@param label       Label variable
@param weights     Weights array. May be null, or any broadcastable shape (with predictions/label arrays).
Note that this is also used for masking (weight of 0 = 'masked out')
@param reduction   Type of reduction to perform for the loss function
@param dimensions  Dimension(s) to apply the loss function on
@return LossInfo - bean with variables etc for the loss function
Mean squared error : L = mean ( ( predicted - label ) ^2 )