#include "../src/NeuronNetwork/FeedForward" #include "../src/NeuronNetwork/Learning/Reinforcement.h" #include "../src/NeuronNetwork/Solution.h" #include #include class X: public Shin::NeuronNetwork::Problem { public: X(const X& a) :q(a.q) {} X(const std::vector &a):q(a) {} std::vector representation() const { return q; } protected: std::vector q; }; int main() { srand(time(NULL)); std::vector p; p.push_back(X(std::vector({0,0}))); p.push_back(X(std::vector({1,1}))); Shin::NeuronNetwork::FeedForward q({2,6,2}); Shin::NeuronNetwork::Learning::Reinforcement b(q); b.getPropagator().setLearningCoeficient(1); int i=0; b.setQualityFunction( [&i](const Shin::NeuronNetwork::Problem &,const Shin::NeuronNetwork::Solution &s)->float { if(i%2==0) { //ocekavame 1 int e=(s[0]-0.80)*15.0;//+(abs(s[1])-0.5)*100.0; return e; }else { //ocekavame 0 int e=(0.20-s[0])*15.0;//+(0.4-abs(s[1]))*100.0; return e; } return 1.0; }); for(i=0;i < 500000000;i++) { if(i==75000) { std::cerr << "SSSSSS1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"; b.setCoef(1); } if(i==150000) { std::cerr << "SSSSSS1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"; b.setCoef(0.51); } if(i==300000) { std::cerr << "SSSSSS2XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"; b.setCoef(0.15); } b.learn(p[i%2]); if(i%100000==0) srand(time(NULL)); if(i%10000==0) for(int j=0;j<2;j++) { std::cerr << j%4 <<". FOR: [" << p[j%4].representation()[0] << "," <