loooot of fixes nad SSE enhacement

This commit is contained in:
2014-11-18 11:09:34 +01:00
parent 207e141cca
commit 0abc0d07dd
28 changed files with 246 additions and 280 deletions

View File

@@ -9,59 +9,45 @@ class X: public Shin::NeuronNetwork::Problem
{
public:
X(const X& a) :q(a.q) {}
X(const std::vector<bool> &a):q(a) {}
std::vector<bool> representation() const
X(const std::vector<float> &a):q(a) {}
X(const std::vector<bool> &a):q() {for(bool s:a) q.push_back((float)s);}
std::vector<float> representation() const
{
return q;
}
protected:
std::vector<bool> q;
std::vector<float> q;
};
int main(int argc)
int main(int argc,char**)
{
srand(time(NULL));
std::vector<Shin::NeuronNetwork::Solution> s;
std::vector<X> p;
//
s.push_back(Shin::NeuronNetwork::Solution(std::vector<double>({1})));
s.push_back(Shin::NeuronNetwork::Solution(std::vector<float>({1})));
p.push_back(X(std::vector<bool>({0})));
s.push_back(Shin::NeuronNetwork::Solution(std::vector<double>({0})));
s.push_back(Shin::NeuronNetwork::Solution(std::vector<float>({0})));
p.push_back(X(std::vector<bool>({1})));
Shin::NeuronNetwork::FeedForwardNetworkQuick q({1,5000,5000,5000});
Shin::NeuronNetwork::FeedForwardNetworkQuick q({1,5000,5000,15000,2});
Shin::NeuronNetwork::Learning::BackPropagation b(q);
if(argc > 1)
{
std::cerr << "THREADING\n";
q.setThreads(4);
q.setThreads(2);
}
#include <chrono>
auto t1 = std::chrono::high_resolution_clock::now();
for(int i=0;i<100;i++)
{
//b.teach(p[i%2],s[i%2]);
q.solve(p[i%2])[0];
//std::cerr << i%2 <<". FOR: [" << p[i%2].representation()[0] << "] res: " << q.solve(p[i%2])[0] << " should be " << s[i%2][0]<<"\n";
}
for(int i=0;i<2;i++)
{
// b.teach(p[i%2],s[i%2]);
// std::cerr << i%4 <<". FOR: [" << p[i%4].representation()[0] << "," <<p[i%4].representation()[0] << "] res: " << q.solve(p[i%4])[0] << " should be " <<
// s[i%4][0]<<"\n";
}
/*
for(int i=0;i<40;i++)
{
b.teach(p[i%4],s[i%4]);
}
b.debugOn();
std::cerr << "LEARNED\n";
for(int i=0;i<4;i++)
{
b.teach(p[i%4],s[i%4]);
std::cerr << i%4 <<". FOR: [" << p[i%4].representation()[0] << "," <<p[i%4].representation()[1] << "] res: " << q.solve(p[i%4])[0] << " should be " <<
s[i%4][0]<<"\n";
}
*/
auto t2 = std::chrono::high_resolution_clock::now();
std::cout << "Time: " << std::chrono::duration_cast<std::chrono::milliseconds>(t2-t1).count() << std::endl;
}