summaryrefslogtreecommitdiff
path: root/Layer
diff options
context:
space:
mode:
Diffstat (limited to 'Layer')
-rw-r--r--Layer/InputLayer.cpp31
-rw-r--r--Layer/InputLayer.h10
-rw-r--r--Layer/Layer.cpp75
-rw-r--r--Layer/Layer.h32
4 files changed, 148 insertions, 0 deletions
diff --git a/Layer/InputLayer.cpp b/Layer/InputLayer.cpp
new file mode 100644
index 0000000..79c0751
--- /dev/null
+++ b/Layer/InputLayer.cpp
@@ -0,0 +1,31 @@
+#include "./InputLayer.h"
+/**
+ * Constructeur par taille
+ * @method InputLayer::InputLayer
+ * @param taille Nombre de neurones dans le layer
+ */
+InputLayer::InputLayer(int taille,FonctionActivation::EnumFonctionActivation fct){
+ membres =std::vector<Neurone *> (taille);
+ nbNeurone = taille;
+ input=std::vector<double>(taille);
+ output= std::vector<double>(taille);
+ for (int i = 0; i < taille; i ++){
+ membres[i] = new Neurone(1, new std::vector<double>(1,1),fct);
+ }
+}
+/**
+ * Méthode de propagation en avant
+ * @method InputLayer::fire
+ * @param input Vecteur en entrées
+ * @param k Coefficient de sigmoid
+ * @return Valeur d'activation
+ */
+std::vector<double> InputLayer::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]->fire({input[i]},k); //faut il activer ou non? OUI!
+ }
+ return output;
+}
diff --git a/Layer/InputLayer.h b/Layer/InputLayer.h
new file mode 100644
index 0000000..aa89a4c
--- /dev/null
+++ b/Layer/InputLayer.h
@@ -0,0 +1,10 @@
+#ifndef _INPUTLAYER_H_
+#define _INPUTLAYER_H_
+#include "./Layer.h"
+
+class InputLayer : public Layer {
+public:
+ InputLayer(int,FonctionActivation::EnumFonctionActivation fct);
+ std::vector<double> fire(std::vector<double>, double);
+};
+#endif
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;
+}
diff --git a/Layer/Layer.h b/Layer/Layer.h
new file mode 100644
index 0000000..501ed86
--- /dev/null
+++ b/Layer/Layer.h
@@ -0,0 +1,32 @@
+#ifndef _LAYER_H_
+#define _LAYER_H_
+#include"../Neurone/Neurone.h"
+#include"../Neurone/NeuroneB.h"
+#include "../Neurone/FonctionActivation.h"
+#include<vector>
+
+class Layer {
+public:
+ enum TypeLayer {
+ INPUT,
+ OUTPUT,
+ HIDDEN
+ };
+protected:
+ double k;
+ int nbNeurone;
+ std::vector<Neurone *> membres;
+ std::vector<double> input;
+ std::vector<double> output;
+ TypeLayer type;
+public:
+ Layer();
+ Layer(TypeLayer,int,int,FonctionActivation::EnumFonctionActivation);
+ Neurone * getNeurone(int index);
+ virtual std::vector<double> fire(std::vector<double>, double);
+ int getNbNeurones();
+ std::vector<double> getInput();
+ std::vector<double> getOutput();
+ void printWeight();
+};
+ #endif