CUDA Networks
Functions
neural_network_get_accuracy.cu File Reference

Implementation of the NeuralNetwork::get_accuracy method. More...

#include "neural_network.h"
#include <cuda_runtime.h>
#include <iostream>
Include dependency graph for neural_network_get_accuracy.cu:

Go to the source code of this file.

Functions

__global__ void calculate_accuracy_kernel (const double *predictions, const double *Y, int size, int *correct_count)
 

Detailed Description

Implementation of the NeuralNetwork::get_accuracy method.

Definition in file neural_network_get_accuracy.cu.

Function Documentation

◆ calculate_accuracy_kernel()

__global__ void calculate_accuracy_kernel ( const double *  predictions,
const double *  Y,
int  size,
int *  correct_count 
)

Definition at line 9 of file neural_network_get_accuracy.cu.

9  {
10  // Calculate global thread index
11  int idx = blockIdx.x * blockDim.x + threadIdx.x;
12 
13  // Check if thread is within bounds
14  if (idx < size) {
15  // Increment correct_count if prediction matches true label
16  if (predictions[idx] == Y[idx]) {
17  atomicAdd(correct_count, 1);
18  }
19  }
20 }