forked from freudenreichan/info2Praktikum-NeuronalesNetz
prepareNeuralNetwork überarbeitet und mit Änderung von Zeile 173 in neuralNetwor.c zu CreateMatrix funktionieren auch die Tests
This commit is contained in:
1 parent
57708089a4
commit
d9f7a2ab3f
2 files changed
+3
-6
No files matched your search
@@ -170,7 +170,7 @@ NeuralNetwork loadModel(const char *path)
|
|||||||
|
|
||||||
static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count)
|
static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count)
|
||||||
{
|
{
|
||||||
Matrix matrix = {NULL, 0, 0};
|
Matrix matrix = createMatrix(0, 0);
|
||||||
|
|
||||||
if(count > 0 && images != NULL)
|
if(count > 0 && images != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
|||||||
fwrite(fileHeader, sizeof(char), strlen(fileHeader), file);
|
fwrite(fileHeader, sizeof(char), strlen(fileHeader), file);
|
||||||
|
|
||||||
if (nn.numberOfLayers > 0 && nn.layers != NULL) {
|
if (nn.numberOfLayers > 0 && nn.layers != NULL) {
|
||||||
// Start Eingangsdimension der ersten Layer schreiben
|
|
||||||
int inputDimension = nn.layers[0].weights.cols;
|
int inputDimension = nn.layers[0].weights.cols;
|
||||||
fwrite(&inputDimension, sizeof(int), 1, file);
|
fwrite(&inputDimension, sizeof(int), 1, file);
|
||||||
|
|
||||||
@@ -22,16 +22,13 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
|||||||
int outputDimension = nn.layers[i].weights.rows;
|
int outputDimension = nn.layers[i].weights.rows;
|
||||||
fwrite(&outputDimension, sizeof(int), 1, file);
|
fwrite(&outputDimension, sizeof(int), 1, file);
|
||||||
|
|
||||||
// Gewichte der Layer schreiben (OutputDim x InputDim)
|
|
||||||
int weightsCount = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
|
int weightsCount = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
|
||||||
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), weightsCount, file);
|
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), weightsCount, file);
|
||||||
|
|
||||||
// Biases der Layer schreiben (OutputDim x 1)
|
|
||||||
int 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);
|
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), biasesCount, file);
|
||||||
}
|
}
|
||||||
// Endsignal (0) schreiben, um die Einleseschleife in loadModel zu beenden
|
int endSignal = 0;
|
||||||
int endSignal = 0;
|
|
||||||
fwrite(&endSignal, sizeof(int), 1, file);
|
fwrite(&endSignal, sizeof(int), 1, file);
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|||||||
Reference in new issue
Block a user