#ifndef __NN__ #define __NN__ #include #include #include #include #include #include #include #include typedef struct Layer { double *weights, *bias; double (*activation)(double x); size_t neurons, input_nodes; } Layer; void nn_network_init_weights(Layer *network, size_t nmemb, size_t input_cols); void nn_network_free_weights(Layer *network, size_t nmemb); void nn_layer_map_activation( double (*activation)(double), double *aout, size_t aout_shape[2], double *zout, size_t zout_shape[2]); void nn_layer_forward(Layer layer, double *out, size_t out_shape[2], double *input, size_t input_shape[2]); void nn_layer_backward( double *weights, size_t weigths_shape[2], double *delta, size_t dcost_cols, double *out_prev, size_t out_cols, Layer layer, double alpha); double sigmoid(double x); double relu(double x); double identity(double x); void nn_forward( double **aout, double **zout, double *input, size_t input_shape[2], Layer network[], size_t network_size); void nn_backwad( double **weights, double **zout, double **outs, size_t n_rows, Layer network[], size_t network_size, double (cost_derivative)(double, double)); void nn_layer_out_delta( double *delta, size_t delta_cols, double *error, size_t error_cols, double *zout, size_t zout_cols, double (*activation_derivative)(double));//TODO void nn_layer_hidden_delta( double *delta, size_t delta_cols, double *delta_next, size_t delta_next_cols, double *weigths_next, size_t weigths_shape[2], double *zout, size_t zout_cols, double (*activation_derivative)(double));//TODO #endif