Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <math.h>
- using namespace std;
- class SSN
- {
- private:
- double x1,x2,x3;
- double y1,y2;
- double *wagi;
- public:
- SSN();
- ~SSN();
- double getx();
- void set_x(double x1, double x2,double x3);
- double neuron_3();
- };
- SSN::SSN()
- {
- this->x1=x1;
- this->x2=x2;
- this->x3=x3;
- this-> wagi=new double[19];
- }
- SSN::~SSN()
- {
- }
- double SSN::getx()
- {
- return this->x1&&x2&&x3;
- }
- void SSN::set_x(double x1, double x2,double x3)
- {
- this->x1=x1;
- this->x2=x2;
- this->x3=x3;
- }
- double SSN::neuron_3()
- {
- for(int i=0;i<19;i++)
- {
- double x = ((double)rand()/(RAND_MAX));
- wagi[i]=x;
- }
- double pierwsza_1,pierwsza_2,pierwsza_3,druga_1,druga_2, wyjscie_1,wyjscie_2,beta=0.5;
- pierwsza_1=x1*wagi[0]+x2*wagi[1]+x3*wagi[2];
- pierwsza_2=x1*wagi[3]+x2*wagi[4]+x3*wagi[5];
- pierwsza_3=x1*wagi[6]+x2*wagi[7]+x3*wagi[8];
- druga_1=pierwsza_1*wagi[9]+pierwsza_2*wagi[10]+pierwsza_3*wagi[11];
- druga_2=pierwsza_1*wagi[12]+pierwsza_2*wagi[13]+pierwsza_3*wagi[14];
- wyjscie_1=druga_1*wagi[15]+druga_2*wagi[16];
- wyjscie_2=druga_1*wagi[17]+druga_2*wagi[18];
- this->y1=wyjscie_1;
- this->y2=wyjscie_2;
- cout<< "Fynkcja liniowa: Wyj1: "<<y1<<" "<<"Wyj2: "<<y2;
- if (y1<0) {
- cout<< "Funkcja progowa unipolarna: Wyj1: -1 ";
- if (y2<0) {
- cout<<"Wyj2: -1";
- } else {
- cout<<"Wyj2: 1";
- }
- } else if (y1>=0) {
- cout<<endl<< "Funkcja progowa unipolarna: Wyj1: 1 ";
- if (y2<0) {
- cout<<"Wyj2: -1";
- } else {
- cout<<"Wyj2: 1";
- }
- }
- cout<<endl;
- cout<< "Funkcja sigmoidalna unipolarna: Wyj1: "<<(1/(1+exp(-beta*y1)))<<" Wyj2: "<<(1/(1+exp(-beta*y2)));
- cout<<endl;
- return 0;
- }
- int main()
- {
- double x1,x2,x3;
- cin>>x1>>x2>>x3;
- SSN a;
- a.getx();
- a.set_x(x1,x2,x3);
- a.neuron_3();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement