neuralNetworkTests v1

This commit is contained in:
Tobias Busch 2025-11-24 22:29:23 +01:00
parent 43ca037b99
commit c1b20e632b
5 changed files with 26 additions and 1 deletions

View File

@ -8,7 +8,32 @@
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
{
// TODO
FILE *file = fopen(path, "wb");
if(file != NULL){
const char *fileTag = "__info2_neural_network_file_format__";
fwrite(fileTag, sizeof(fileTag[0]), strlen(fileTag), file);
int inputDimension = nn.layers[0].weights.cols;
fwrite(&inputDimension,sizeof(inputDimension), 1, file);
for (int i = 0; i < nn.numberOfLayers; i++)
{
unsigned int outputDimension = nn.layers[i].weights.rows;
fwrite(&outputDimension, sizeof(outputDimension), 1, file);
unsigned int numWeights = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), numWeights, file);
unsigned int numBiases = nn.layers[i].biases.rows * nn.layers[i].biases.cols;
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), 1, file);
}
unsigned int outputDimension = 0;
fwrite(&outputDimension, sizeof(outputDimension), 1, file);
fclose(file);
}
}
void test_loadModelReturnsCorrectNumberOfLayers(void)

Binary file not shown.

Binary file not shown.