-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
41 lines (33 loc) · 1.21 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "autoencoder.h"
#include "utils.h"
#include "nifti_loader.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
if (argc < 2) {
fprintf(stderr, "Usage: %s <nifti_file>\n", argv[0]);
return 1;
}
const char* nifti_file = argv[1];
NiftiImage* image = load_nifti(nifti_file);
if (!image) {
return 1;
}
int inputDepth = image->depth, inputHeight = image->height, inputWidth = image->width;
int kernelSize = 3;
float* inputData = image->data;
float* targetData = (float*)safe_malloc(inputDepth * inputHeight * inputWidth * sizeof(float));
// Use the input image as the target for simplicity
for (int i = 0; i < inputDepth * inputHeight * inputWidth; i++) {
targetData[i] = inputData[i];
}
Autoencoder autoencoder;
init_autoencoder(&autoencoder, inputDepth, inputHeight, inputWidth, kernelSize);
int epochs = 100;
float learning_rate = 0.01;
train_autoencoder(&autoencoder, inputData, targetData, inputDepth * inputHeight * inputWidth, epochs, learning_rate);
free_autoencoder(&autoencoder);
free_nifti(image);
free(targetData);
return 0;
}