XCSF 1.4.8
XCSF learning classifier system
Loading...
Searching...
No Matches
pred_neural.h
Go to the documentation of this file.
1/*
2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, either version 3 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 */
15
24#pragma once
25
26#include "neural.h"
27#include "neural_activations.h"
28#include "neural_layer.h"
29#include "prediction.h"
30#include "xcsf.h"
31
35struct PredNeural {
36 struct Net net;
37};
38
39void
41
42char *
43pred_neural_param_json_import(struct XCSF *xcsf, cJSON *json);
44
45bool
46pred_neural_crossover(const struct XCSF *xcsf, const struct Cl *c1,
47 const struct Cl *c2);
48
49bool
50pred_neural_mutate(const struct XCSF *xcsf, const struct Cl *c);
51
52double
53pred_neural_eta(const struct XCSF *xcsf, const struct Cl *c, const int layer);
54
55int
56pred_neural_connections(const struct XCSF *xcsf, const struct Cl *c,
57 const int layer);
58
59int
60pred_neural_layers(const struct XCSF *xcsf, const struct Cl *c);
61
62int
63pred_neural_neurons(const struct XCSF *xcsf, const struct Cl *c,
64 const int layer);
65
66double
67pred_neural_size(const struct XCSF *xcsf, const struct Cl *c);
68
69size_t
70pred_neural_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
71
72size_t
73pred_neural_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
74
75void
76pred_neural_compute(const struct XCSF *xcsf, const struct Cl *c,
77 const double *x);
78
79void
80pred_neural_copy(const struct XCSF *xcsf, struct Cl *dest,
81 const struct Cl *src);
82
83void
84pred_neural_free(const struct XCSF *xcsf, const struct Cl *c);
85
86void
87pred_neural_init(const struct XCSF *xcsf, struct Cl *c);
88
89void
90pred_neural_print(const struct XCSF *xcsf, const struct Cl *c);
91
92void
93pred_neural_update(const struct XCSF *xcsf, const struct Cl *c, const double *x,
94 const double *y);
95
96void
97pred_neural_expand(const struct XCSF *xcsf, const struct Cl *c);
98
99void
100pred_neural_ae_to_classifier(const struct XCSF *xcsf, const struct Cl *c,
101 const int n_del);
102
103char *
104pred_neural_json_export(const struct XCSF *xcsf, const struct Cl *c);
105
106void
107pred_neural_json_import(const struct XCSF *xcsf, struct Cl *c,
108 const cJSON *json);
109
An implementation of a multi-layer perceptron neural network.
Neural network activation functions.
Interface for neural network layers.
char * pred_neural_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the neural network parameters from a cJSON object.
int pred_neural_layers(const struct XCSF *xcsf, const struct Cl *c)
Returns the number of layers within a neural network prediction.
bool pred_neural_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a neural network prediction.
size_t pred_neural_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a neural network prediction to a file.
int pred_neural_connections(const struct XCSF *xcsf, const struct Cl *c, const int layer)
Returns the number of active connections in a neural prediction layer.
void pred_neural_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Forward propagates a neural network prediction with a provided input.
void pred_neural_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a neural network prediction.
void pred_neural_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a neural network prediction.
Definition pred_neural.c:58
void pred_neural_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises a neural network prediction.
Definition pred_neural.c:45
int pred_neural_neurons(const struct XCSF *xcsf, const struct Cl *c, const int layer)
Returns the number of neurons in a neural prediction layer.
void pred_neural_ae_to_classifier(const struct XCSF *xcsf, const struct Cl *c, const int n_del)
Removes prediction (decoder) layers and inserts softmax output layer.
void pred_neural_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a neural prediction from a cJSON object.
void pred_neural_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a neural network prediction from one classifier to another.
Definition pred_neural.c:73
static struct PredVtbl const pred_neural_vtbl
Multi-layer perceptron neural network prediction implemented functions.
void pred_neural_expand(const struct XCSF *xcsf, const struct Cl *c)
Creates and inserts a hidden layer before the prediction output layer.
double pred_neural_eta(const struct XCSF *xcsf, const struct Cl *c, const int layer)
Returns the gradient descent rate of a neural prediction layer.
void pred_neural_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Backward propagates and updates a neural network prediction.
Definition pred_neural.c:91
bool pred_neural_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy function since neural predictions do not perform crossover.
double pred_neural_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a neural network prediction.
void pred_neural_param_defaults(struct XCSF *xcsf)
Initialises default neural prediction parameters.
size_t pred_neural_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a neural network prediction from a file.
char * pred_neural_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a neural prediction.
Interface for classifier predictions.
Classifier data structure.
Definition xcsf.h:45
Neural network data structure.
Definition neural.h:48
Multi-layer perceptron neural network prediction data structure.
Definition pred_neural.h:35
struct Net net
Neural network.
Definition pred_neural.h:36
Prediction interface data structure.
Definition prediction.h:96
XCSF data structure.
Definition xcsf.h:85
XCSF data structures.