small improvements

This commit is contained in:
Jonas Urban 2025-11-15 19:24:08 +01:00
parent 284a313751
commit 4e238675c8

View File

@ -55,27 +55,18 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
// input und output dimension schreiben
int inputDim = nn.layers[0].weights.cols;
int outputDim = nn.layers[0].weights.rows;
fwrite(&inputDim, sizeof(int), 1, file);
fwrite(&outputDim, sizeof(int), 1, file);
// erstes Layer schreiben
int weightCount = nn.layers[0].weights.rows * nn.layers[0].weights.cols;
fwrite(nn.layers[0].weights.buffer, sizeof(MatrixType), weightCount, file);
int biasesCount = nn.layers[0].biases.rows * nn.layers[0].biases.cols;
fwrite(nn.layers[0].biases.buffer, sizeof(MatrixType), biasesCount, file);
// für weiter Layer nur outputDimension schreiben
for (unsigned int i = 1; i < nn.numberOfLayers; i++)
for (unsigned int i = 0; i < nn.numberOfLayers; i++)
{
outputDim = nn.layers[i].weights.rows;
int outputDim = nn.layers[i].weights.rows;
fwrite(&outputDim, sizeof(int), 1, file);
weightCount = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
int weightCount = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), weightCount, file);
biasesCount = nn.layers[i].biases.rows * nn.layers[i].biases.cols;
int biasesCount = nn.layers[i].biases.rows * nn.layers[i].biases.cols;
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), biasesCount, file);
}