uses c for speed with python interface custom neural network architecture
- make c modules with each type of activation
- test activations
- droput
- test dropout
- make c activations hook up into one another
- test layers
- create nn
- test nn
- create init function
- test
- add and edit layers
- test
- feedforward
- test
- thread computation
- test
- model archetirure with string
- test
- create python wrapper
- create nn objection
- make everything interfaceable
- save and load nn in python
- test
- allow user to add activation functions
- rewrite ga from python into c
- test all python code
- code up some examples
- Reminder most C structs and functions are accessible from Python
-
a_relu(double *inputs, double *weights, double bias, int length)
- Returns the ReLU function of the given weights and biases as a
double
- Returns the ReLU function of the given weights and biases as a
-
a_sigmoid(double *inputs, double *weights, double bias, int length)
- Returns the sigmoid function of the given weights and biases as a
double
- Returns the sigmoid function of the given weights and biases as a
-
double a_tanh(double *inputs, double *weights, double bias, int length)
- Returns the hyperbolic tangent function of the given weights and biases as a
double
- Returns the hyperbolic tangent function of the given weights and biases as a
-
layer
- Struct
int
input lengthint
length of the layerdouble
array of biases- 2 dimensional
double
array of weights char
representing activation type
-
init_weights(struct layer *sheet)
- Void
- Generates a 2 dimensional empty array of
double
s for thelayer
struct
-
init_biases(struct layer *sheet)
- Void
- Generates an empty array of
double
s for thelayer
struct
-
output(struct layer *sheet, double *inputs)
- Returns a double array
- Uses activation from
layer
to calculate the output given an array ofdouble
s
-
nn
- Struct
- Array of
layer
structs int
length
-
network_init(struct nn *network, int randomized)
- Initializes empty arrays of weights and biases from array of
layer
s
- Initializes empty arrays of weights and biases from array of
-
struct nn create_nn(char *arc)
- Generates an
nn
struct based on a given string architecture - String architecture looks like the following:
"xi|xa|"
where x is anyint
and a is any valid activation function"xa|"
is repeated for each layer innn
struct
- Generates an
-
add_layer(struct nn *network, char *arc_part)
- Adds a
layer
struct tonn
's array oflayer
s *arc_part
must be in the form of"xa|"
- Adds a
-
feedforward(struct nn *network, double *inputs)
- Calculates output of network given a set of inputs in a
double
array
- Calculates output of network given a set of inputs in a
-
a_relu(double *inputs, double *weights, double bias, int length)
- Returns the ReLU function of the given weights and biases as a
double
- Returns the ReLU function of the given weights and biases as a
-
a_sigmoid(double *inputs, double *weights, double bias, int length)
- Returns the sigmoid function of the given weights and biases as a
double
- Returns the sigmoid function of the given weights and biases as a
-
double a_tanh(double *inputs, double *weights, double bias, int length)
- Returns the hyperbolic tangent function of the given weights and biases as a
double
- Returns the hyperbolic tangent function of the given weights and biases as a
-
layer
- CTypes Struct
int
input lengthint
length of the layerdouble
array of biases- 2 dimensional
double
array of weights char
representing activation type
-
init_weights(struct layer *sheet)
- Void
- Generates a 2 dimensional empty array of
double
s for thelayer
struct
-
init_biases(struct layer *sheet)
- Void
- Generates an empty array of
double
s for thelayer
struct
-
output(struct layer *sheet, double *inputs)
- Returns a double array
- Uses activation from
layer
to calculate the output given an array ofdouble
s
-
nn
- CTypes Struct
- Array of
layer
structs int
length
-
network_init(struct nn *network, int randomized)
- Initializes empty arrays of weights and biases from array of
layer
s
- Initializes empty arrays of weights and biases from array of
-
struct nn create_nn(char *arc)
- Generates an
nn
struct based on a given string architecture - String architecture looks like the following:
"xi|xa|"
where x is anyint
and a is any valid activation function"xa|"
is repeated for each layer innn
struct
- Generates an
-
add_layer(struct nn *network, char *arc_part)
- Adds a
layer
struct tonn
's array oflayer
s *arc_part
must be in the form of"xa|"
- Adds a
-
feedforward(struct nn *network, double *inputs)
- Calculates output of network given a set of inputs in a
double
array
- Calculates output of network given a set of inputs in a
-
init_c
- Initializes shared object file with C functions
-
toCDouble(value)
- Converts Python numeric to C
double
- Converts Python numeric to C
-
toCInt(value)
- Converts Python numeric to C
int
- Converts Python numeric to C
-
toCChar(value)
- Converts Python character to C
char
- Converts Python character to C
-
CValtoPyValue(c_value)
- Generic C value conversion to Python object
-
toCDoubleArray(arr)
- Converts numeric Python array to array of C
double
s
- Converts numeric Python array to array of C
-
CDoubletoPyArray(arr, length)
- Converts C
double
array to Python array given the length as anint
- Converts C
-
doubleToArrayToPointer(arr, shape)
- Converts 2 dimensional numeric Python array to 2 dimensional C array of
double
s shape
must be a tuple,(n, m)
that specifies dimensions of array
- Converts 2 dimensional numeric Python array to 2 dimensional C array of
-
writeToLayer(layer, arr, shape)
- Writes double array to
layer
givenshape
shape
must be a tuple,(n, m)
that specifies dimensions of arraylayer
must be CTypeslayer
struct
- Writes double array to
- create package: https://stackoverflow.com/questions/47360113/compile-c-library-on-pip-install
- more activations to add: https://en.wikipedia.org/wiki/Activation_function
- passing activation as function arg: https://stackoverflow.com/questions/9410/how-do-you-pass-a-function-as-a-parameter-in-c#9413