From 6ca8a31143f087f3bc470d39eb3c00156443802a Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 23 Nov 2023 08:38:59 -0800 Subject: Formatting. --- src/lib/include/neuralnet/matrix.h | 15 ++++++++++----- src/lib/include/neuralnet/neuralnet.h | 8 +++++--- src/lib/include/neuralnet/train.h | 20 +++++++++----------- 3 files changed, 24 insertions(+), 19 deletions(-) (limited to 'src/lib/include') diff --git a/src/lib/include/neuralnet/matrix.h b/src/lib/include/neuralnet/matrix.h index 0cb40cf..b7281bf 100644 --- a/src/lib/include/neuralnet/matrix.h +++ b/src/lib/include/neuralnet/matrix.h @@ -33,7 +33,8 @@ void nnMatrixToArray(const nnMatrix* in, R* out); void nnMatrixRowToArray(const nnMatrix* in, int row, R* out); /// Copy a column from a source to a target matrix. -void nnMatrixCopyCol(const nnMatrix* in, nnMatrix* out, int col_in, int col_out); +void nnMatrixCopyCol( + const nnMatrix* in, nnMatrix* out, int col_in, int col_out); /// Mutable borrow of a matrix. nnMatrix nnMatrixBorrow(nnMatrix* in); @@ -56,20 +57,24 @@ void nnMatrixMul(const nnMatrix* left, const nnMatrix* right, nnMatrix* out); /// /// This function multiples two matrices row-by-row instead of row-by-column. /// nnMatrixMul(A, B, O) == nnMatrixMulRows(A, B^T, O). -void nnMatrixMulRows(const nnMatrix* left, const nnMatrix* right, nnMatrix* out); +void nnMatrixMulRows( + const nnMatrix* left, const nnMatrix* right, nnMatrix* out); /// Matrix multiply-add. /// /// out = left + (right * scale) -void nnMatrixMulAdd(const nnMatrix* left, const nnMatrix* right, R scale, nnMatrix* out); +void nnMatrixMulAdd( + const nnMatrix* left, const nnMatrix* right, R scale, nnMatrix* out); /// Matrix multiply-subtract. /// /// out = left - (right * scale) -void nnMatrixMulSub(const nnMatrix* left, const nnMatrix* right, R scale, nnMatrix* out); +void nnMatrixMulSub( + const nnMatrix* left, const nnMatrix* right, R scale, nnMatrix* out); /// Hadamard product of two matrices. -void nnMatrixMulPairs(const nnMatrix* left, const nnMatrix* right, nnMatrix* out); +void nnMatrixMulPairs( + const nnMatrix* left, const nnMatrix* right, nnMatrix* out); /// Add two matrices. void nnMatrixAdd(const nnMatrix* left, const nnMatrix* right, nnMatrix* out); diff --git a/src/lib/include/neuralnet/neuralnet.h b/src/lib/include/neuralnet/neuralnet.h index 1cf1c53..05c9406 100644 --- a/src/lib/include/neuralnet/neuralnet.h +++ b/src/lib/include/neuralnet/neuralnet.h @@ -5,7 +5,7 @@ typedef struct nnMatrix nnMatrix; typedef struct nnNeuralNetwork nnNeuralNetwork; -typedef struct nnQueryObject nnQueryObject; +typedef struct nnQueryObject nnQueryObject; /// Neuron activation. typedef enum nnActivation { @@ -15,7 +15,8 @@ typedef enum nnActivation { } nnActivation; /// Create a network. -nnNeuralNetwork* nnMakeNet(int num_layers, const int* layer_sizes, const nnActivation* activations); +nnNeuralNetwork* nnMakeNet( + int num_layers, const int* layer_sizes, const nnActivation* activations); /// Delete the network and free its internal memory. void nnDeleteNet(nnNeuralNetwork**); @@ -36,7 +37,8 @@ void nnSetBiases(nnNeuralNetwork*, const R* biases); void nnQuery(const nnNeuralNetwork*, nnQueryObject*, const nnMatrix* input); /// Query the network, array version. -void nnQueryArray(const nnNeuralNetwork*, nnQueryObject*, const R* input, R* output); +void nnQueryArray( + const nnNeuralNetwork*, nnQueryObject*, const R* input, R* output); /// Create a query object. /// diff --git a/src/lib/include/neuralnet/train.h b/src/lib/include/neuralnet/train.h index 79f8e7b..6d811c2 100644 --- a/src/lib/include/neuralnet/train.h +++ b/src/lib/include/neuralnet/train.h @@ -14,18 +14,18 @@ typedef struct nnMatrix nnMatrix; /// activation with many inputs. Thus, a (0,1) initialization is really /// (0,scale), for example. typedef enum nnWeightInitStrategy { - nnWeightInit01, // (0,1) range. - nnWeightInit11, // (-1,+1) range. - nnWeightInitNormal, // Normal distribution. + nnWeightInit01, // (0,1) range. + nnWeightInit11, // (-1,+1) range. + nnWeightInitNormal, // Normal distribution. } nnWeightInitStrategy; /// Network training parameters. typedef struct nnTrainingParams { - R learning_rate; - int max_iterations; - uint64_t seed; + R learning_rate; + int max_iterations; + uint64_t seed; nnWeightInitStrategy weight_init; - bool debug; + bool debug; } nnTrainingParams; /// Train the network. @@ -36,7 +36,5 @@ typedef struct nnTrainingParams { /// |targets| is a matrix of targets, one row per target and as many columns as /// the target's dimension. void nnTrain( - nnNeuralNetwork*, - const nnMatrix* inputs, - const nnMatrix* targets, - const nnTrainingParams*); + nnNeuralNetwork*, const nnMatrix* inputs, const nnMatrix* targets, + const nnTrainingParams*); -- cgit v1.2.3