-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivation.h
More file actions
28 lines (23 loc) · 873 Bytes
/
activation.h
File metadata and controls
28 lines (23 loc) · 873 Bytes
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
#ifndef __ACTIVATION_H__
#define __ACTIVATION_H__
#include "matrix.h"
typedef void(*activation_t)(Matrix* in, Matrix* out);
typedef void(*derivative_t)(Matrix* in, Matrix* out);
typedef struct {
char* name;
activation_t func;
derivative_t derivative;
} Activation;
Activation* activation_init(char* name, activation_t func, derivative_t derivative);
void activation_free(Activation* p);
void activation_apply(Activation* a, Matrix* in, Matrix* out);
// Some pre-defined activation functions and their derivatives
void identity(Matrix* in, Matrix* out);
void one(Matrix* in, Matrix* out);
void relu(Matrix* in, Matrix* out);
void relu_derivative(Matrix* in, Matrix* out);
void softmax(Matrix* in, Matrix* out);
void softmax_derivative(Matrix* in, Matrix* out);
void sigmoid(Matrix* in, Matrix* out);
void sigmoid_derivative(Matrix* in, Matrix* out);
#endif