summaryrefslogtreecommitdiff
path: root/Layer/Layer.cpp
diff options
context:
space:
mode:
authorGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:12:36 +0200
committerGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:12:36 +0200
commitb4c345e6a5fa929ba20eac19183b9c777055f52d (patch)
tree23a0232f2526c5ab7f53391609a8a0a5960865f0 /Layer/Layer.cpp
Initial commit
Diffstat (limited to 'Layer/Layer.cpp')
-rw-r--r--Layer/Layer.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/Layer/Layer.cpp b/Layer/Layer.cpp
new file mode 100644
index 0000000..52b9861
--- /dev/null
+++ b/Layer/Layer.cpp
@@ -0,0 +1,75 @@
+#include"./Layer.h"
+
+/**
+ * Constructeur par défauts
+ * @method Layer::Layer
+ */
+Layer::Layer(){}
+/**
+ * Constructeur avec arguments
+ * @method Layer::Layer
+ * @param type Type de layer
+ * @param nbneur Nombre de neurone
+ * @param nbinput Nombre d'entrée par neurone
+ */
+Layer::Layer(TypeLayer type,int nbneur, int nbinput, FonctionActivation::EnumFonctionActivation fct):nbNeurone(nbneur)
+{
+ membres = std::vector<Neurone*>(nbneur);
+ input=std::vector<double>(nbinput);
+ output= std::vector<double>(nbneur);
+ for (int i =0; i < nbneur; i ++){
+ membres[i]= new NeuroneB(nbinput,fct);
+ }
+}
+/**
+* @method Layer::getNeurone
+* @param index index
+* @return Neurone
+*/
+Neurone * Layer::getNeurone (int index){
+ return membres[index];
+}
+/**
+ * Affiche les poids
+ * @method Layer::printWeight
+ */
+void Layer::printWeight(){
+ for (int i =0; i < nbNeurone;i++){
+ std::cout<<"Neurone numero : "<<i<<std::endl;
+ membres[i]->printWeight();
+ }
+}
+/**
+ * @method Layer::getNbNeurones
+ * @return Nombre de neurones
+ */
+int Layer::getNbNeurones(){
+ return nbNeurone;
+}
+/**
+ * @method Layer::getInput
+ * @return Retourne le vecteur d'entrées
+ */
+std::vector<double> Layer::getInput(){
+ return input;
+}
+std::vector<double> Layer::getOutput(){
+ return output;
+}
+
+/**
+ * Propagation en avant
+ * @method Layer::fire
+ * @param input Vecteur en entrées
+ * @param k Coefficient de sigmoid
+ * @return Vecteur des valeurs d'activations
+ */
+std::vector<double> Layer::fire(std::vector<double> input, double k) {
+ for (unsigned int i =0; i < input.size(); i ++){
+ this->input[i] = input[i];
+ }
+ for (int i = 0; i < nbNeurone; i++){
+ output[i] = membres[i]->fw_activate(membres[i]->fw_sum(input),k);
+ }
+return output;
+}