Esempio n. 1
0
    public static Tensor GetEvalFunction(NeuralNetworkEvalFunction lossFunction, Tensor labels, Tensor calculatedOutputs)
    {
        switch (lossFunction)
        {
        case NeuralNetworkEvalFunction.sigmoid_cross_entropy_with_logits: return(tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels, calculatedOutputs)));

        case NeuralNetworkEvalFunction.softmax_cross_entropy_with_logits: return(tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels, calculatedOutputs)));

        case NeuralNetworkEvalFunction.softmax_cross_entropy_with_logits_v2: return(tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels, calculatedOutputs)));

        case NeuralNetworkEvalFunction.ClassificationError: return(NetworkBuilder.ClassificationError(calculatedOutputs, labels));

        case NeuralNetworkEvalFunction.MeanSquaredError: return(MeanSquaredError(labels, calculatedOutputs));

        case NeuralNetworkEvalFunction.MeanAbsoluteError: return(NetworkBuilder.MeanAbsoluteError(calculatedOutputs, labels));

        case NeuralNetworkEvalFunction.MeanAbsolutePercentageError: return(NetworkBuilder.MeanAbsolutePercentageError(calculatedOutputs, labels));

        default:
            throw new InvalidOperationException("Unexpected " + lossFunction);
        }
    }