generated from freudenreichan/info2Praktikum-NeuronalesNetz
neuralNetworkTests v1
This commit is contained in:
parent
43ca037b99
commit
c1b20e632b
@ -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.
BIN
runMatrixTests
BIN
runMatrixTests
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user