All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cuda.evaluation.EvaluationKernel.cu Maven / Gradle / Ivy

Go to download

Komputation is a neural network framework for the JVM written in the Kotlin programming language.

There is a newer version: 0.12.5
Show newest version
__global__ void evaluationKernel (
    int batchStart,
    int numberRows,
    int numberColumns,
    int numberEntriesPerInstance,
    float* predictions,
    float* targets,
    int* result) {

    int indexInstance = blockIdx.x;
    int instanceStart = indexInstance * numberEntriesPerInstance;

    for(int indexColumn = 0; indexColumn < numberColumns; indexColumn++) {

        int instanceColumnStart = instanceStart + indexColumn * numberRows;
        int instanceColumnEnd = instanceColumnStart + numberRows;

        float maximumPrediction = 0;
        int maximumPredictionIndex = -1;

        float maximumTarget = 0;
        int maximumTargetIndex = -1;

        for(int indexEntry = instanceColumnStart; indexEntry < instanceColumnEnd; indexEntry++) {

            float prediction = predictions[indexEntry];
            float target = targets[indexEntry];

            if(prediction > maximumPrediction) {

                maximumPrediction = prediction;
                maximumPredictionIndex = indexEntry;

            }

            if(target > maximumTarget) {

                maximumTarget = target;
                maximumTargetIndex = indexEntry;

            }

        }

        if(maximumPredictionIndex != maximumTargetIndex) {

            result[batchStart + indexInstance] = 0;

            return;

        }

    }

    result[batchStart + indexInstance] = 1;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy