HolyFuckItsAlive #13

Merged
jastornig merged 105 commits from Delta-Error-Test into main 2023-09-23 22:27:54 +02:00
2 changed files with 10 additions and 4 deletions
Showing only changes of commit 614cfef7f2 - Show all commits

View file

@ -2,8 +2,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#define MAX_BYTES 100
static int RANDOMIZED = 0;
// operational functions
Matrix* matrix_create(int rows, int columns) {
@ -17,7 +19,7 @@ Matrix* matrix_create(int rows, int columns) {
// allocate memory for the numbers (2D-Array)
matrix->numbers = malloc(sizeof(double*) * rows);
for (int i = 0; i < rows; i++) {
matrix->numbers[i] = malloc(sizeof(double) * columns);
matrix->numbers[i] = calloc(sizeof(double), columns);
}
// return the pointer to the allocated memory
@ -189,7 +191,8 @@ Matrix* apply(double (*function)(double), Matrix* matrix) {
// apply the function to all values in the matrix
for (int i = 0; i < matrix->rows; i++) {
for (int j = 0; j < matrix->columns; j++) {
matrix->numbers[i][j] = (*function)(matrix->numbers[i][j]);
result_matrix->numbers[i][j] = (*function)(matrix->numbers[i][j]);
int k = 0;
}
}
@ -350,6 +353,10 @@ int matrix_argmax(Matrix* matrix) {
void matrix_randomize(Matrix* matrix, int n) {
if(!RANDOMIZED){
srand(time(NULL));
RANDOMIZED = 1;
}
//make a min and max
double min = -1.0f / sqrt(n);
double max = 1.0f / sqrt(n);

View file

@ -159,11 +159,10 @@ Matrix* predict(Neural_Network* network, Matrix* image_data) {
//void batch_train_network(Neural_Network* network, Image** images, int size);
double relu(double input) {
if (input < 0){
if (input <= 0){
return 0.0;
}
return input;
//TODO: relu formel
}
Matrix* softmax(Matrix* matrix) {