new test, and multithreading in FFQ, MT in BP not working
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "../src/NeuronNetwork/FeedForwardQuick"
|
||||
#include "../src/NeuronNetwork/Learning/Reinforcement"
|
||||
#include "../src/NeuronNetwork/Learning/OpticalBackPropagation"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
@@ -20,10 +21,19 @@ class X: public Shin::NeuronNetwork::Problem
|
||||
int main()
|
||||
{
|
||||
|
||||
for (int test=0;test<2;test++)
|
||||
for (int test=0;test<3;test++)
|
||||
{
|
||||
Shin::NeuronNetwork::FeedForwardNetworkQuick q({2,6,1});
|
||||
Shin::NeuronNetwork::Learning::Reinforcement b(q);
|
||||
double targetQuality =1.2;
|
||||
if(test==2)
|
||||
{
|
||||
targetQuality =1.62;
|
||||
std::cerr << "Testing with OBP ...\n";
|
||||
|
||||
b.setPropagator(new Shin::NeuronNetwork::Learning::OpticalBackPropagation(q));
|
||||
b.getPropagator().setLearningCoeficient(3);
|
||||
}
|
||||
b.setQualityFunction(
|
||||
[](const Shin::NeuronNetwork::Problem &pr,const Shin::NeuronNetwork::Solution &s)->double
|
||||
{
|
||||
@@ -42,10 +52,10 @@ int main()
|
||||
|
||||
if(expect==0)
|
||||
{
|
||||
expect=0.35-s[0];
|
||||
expect=0.33-s[0];
|
||||
}else
|
||||
{
|
||||
expect=s[0]-0.65;
|
||||
expect=s[0]-0.67;
|
||||
}
|
||||
|
||||
// std::cerr << " returnning " << expect*5.0 << "\n";
|
||||
@@ -62,7 +72,7 @@ int main()
|
||||
p.push_back( new X(std::vector<bool>({0,1})));
|
||||
p.push_back(new X(std::vector<bool>({1,1})));
|
||||
|
||||
if(test)
|
||||
if(test==1)
|
||||
{
|
||||
std::cerr << "Testing with entropy ...\n";
|
||||
b.getPropagator().allowEntropy();
|
||||
@@ -70,7 +80,6 @@ int main()
|
||||
{
|
||||
std::cerr << "Testing without entropy ...\n";
|
||||
}
|
||||
double targetQuality =1.5;
|
||||
|
||||
for(int i=0;i < 500000000;i++)
|
||||
{
|
||||
@@ -78,7 +87,7 @@ int main()
|
||||
|
||||
if(i%100000==0)
|
||||
srand(time(NULL));
|
||||
if(i%20000==0 || err > targetQuality)
|
||||
if(i%40000==0 || err > targetQuality)
|
||||
{
|
||||
std::cerr << i << " ("<< err <<").\n";
|
||||
for(int j=0;j<4;j++)
|
||||
|
||||
Reference in New Issue
Block a user