generated from freudenreichan/info2Praktikum-NeuronalesNetz
Cleanup and edit comments neuralNetwork FIles
This commit is contained in:
parent
0c85fb19bc
commit
1f1a7a23b1
@ -164,7 +164,6 @@ NeuralNetwork loadModel(const char *path)
|
||||
|
||||
assignActivations(model);
|
||||
}
|
||||
printf("%d\n", model.numberOfLayers);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@ -13,30 +13,30 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||
if(file != NULL){
|
||||
const char *fileTag = "__info2_neural_network_file_format__";
|
||||
|
||||
// Write file header
|
||||
//Write header
|
||||
fwrite(fileTag, sizeof(char), strlen(fileTag), file);
|
||||
|
||||
// Write the input dimension of the first layer
|
||||
//Write the input dimension of the first layer
|
||||
if(nn.numberOfLayers > 0){
|
||||
fwrite(&nn.layers[0].weights.cols, sizeof(int), 1, file);
|
||||
}
|
||||
|
||||
// Write dimensions and data for each layer
|
||||
//Write each layer into file
|
||||
for(int i = 0; i < nn.numberOfLayers; i++){
|
||||
|
||||
// Write output dimension (rows of weights)
|
||||
//Write output dimension
|
||||
fwrite(&nn.layers[i].weights.rows, sizeof(int), 1, file);
|
||||
|
||||
// Write weight matrix data
|
||||
//Write weight data
|
||||
int weightSize = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
|
||||
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), weightSize, file);
|
||||
|
||||
// Write bias matrix data
|
||||
//Write bias data
|
||||
int biasSize = nn.layers[i].biases.rows * nn.layers[i].biases.cols;
|
||||
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), biasSize, file);
|
||||
}
|
||||
|
||||
// Write terminating 0 to signal end of layers
|
||||
//EOF Terminator
|
||||
int zero = 0;
|
||||
fwrite(&zero, sizeof(int), 1, file);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user