initiate Neuronales_Netz
This commit is contained in:
1 parent
284cc80e9f
commit
37caf9a24e
19 files changed
+415
-8
No files matched your search
@@ -9,6 +9,31 @@
|
||||
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);
|
||||
fwrite(&nn.layers[0].weights.cols, sizeof(int), 1, file);
|
||||
fwrite(&nn.layers[0].weights.rows, sizeof(int), 1, file);
|
||||
|
||||
for(int i = 0; i < nn.numberOfLayers; i++)
|
||||
{
|
||||
unsigned int sizeWeights = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
|
||||
unsigned int sizeBiases = nn.layers[i].biases.rows;
|
||||
|
||||
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), sizeWeights, file);
|
||||
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), sizeBiases, file);
|
||||
|
||||
if(i < nn.numberOfLayers - 1)
|
||||
{
|
||||
fwrite(&nn.layers[i].weights.cols, sizeof(unsigned int), 1, file);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||
|
||||
Reference in new issue
Block a user