generated from freudenreichan/info2Praktikum-NeuronalesNetz
Optionale Aufgabe: eigene Ziffern malen
Taste D wechselt in den Malmodus (linke Maus malen, rechte Maus radieren, C leeren). Die Zeichnung wird live klassifiziert; vor der Vorhersage wird sie wie die MNIST-Daten ueber den Schwerpunkt zentriert. Da raylib.h selbst einen Typ Matrix definiert, bekommt showMnist eine Klassifizierungsfunktion aus main.c uebergeben statt neuralNetwork.h einzubinden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d6a86f293
commit
9356a19fb0
3 files changed
+261
-8
No files matched your search
+16
-1
@@ -4,6 +4,21 @@
|
||||
#include "mnistVisualization.h"
|
||||
#include "neuralNetwork.h"
|
||||
|
||||
static int classifyImage(const GrayScaleImage *image, const void *context)
|
||||
{
|
||||
const NeuralNetwork *model = (const NeuralNetwork *)context;
|
||||
unsigned char *prediction = predict(*model, image, 1);
|
||||
int label = -1;
|
||||
|
||||
if(prediction != NULL)
|
||||
{
|
||||
label = prediction[0];
|
||||
free(prediction);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const unsigned int windowWidth = 800;
|
||||
@@ -34,7 +49,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(predictions != NULL)
|
||||
{
|
||||
showMnist(windowWidth, windowHeight, series, predictions);
|
||||
showMnist(windowWidth, windowHeight, series, predictions, classifyImage, &model);
|
||||
free(predictions);
|
||||
exitCode = EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user