66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#include <NeuralNetwork/BasisFunction/Linear.h>
|
|
|
|
#include <iostream>
|
|
#include <cassert>
|
|
#include <chrono>
|
|
|
|
int main() {
|
|
{
|
|
NeuralNetwork::BasisFunction::Linear l;
|
|
assert(39.0==l.compute({1,2,3,5},{1,2,3,5}));
|
|
assert(39.0==l.computeStreaming({1,2,3,5},{1,2,3,5}));
|
|
}
|
|
{
|
|
NeuralNetwork::BasisFunction::Linear l;
|
|
assert(88.0==l.computeStreaming({1,2,3,5,7},{1,2,3,5,7}));
|
|
assert(88.0==l.compute({1,2,3,5,7},{1,2,3,5,7}));
|
|
}
|
|
{
|
|
NeuralNetwork::BasisFunction::Linear l;
|
|
std::vector<float> w;
|
|
for(int in=0;in<100;in++) {
|
|
w.push_back(2);
|
|
}
|
|
assert(400.0==l.computeStreaming(w,w));
|
|
assert(400.0==l.compute(w,w));
|
|
}
|
|
{
|
|
NeuralNetwork::BasisFunction::Linear l;
|
|
std::vector<float> w;
|
|
for(int in=0;in<55;in++) {
|
|
w.push_back(2);
|
|
}
|
|
assert(220.0==l.computeStreaming(w,w));
|
|
assert(220.0==l.compute(w,w));
|
|
}
|
|
/*
|
|
std::vector<float> w;
|
|
std::vector<float> i;
|
|
for(int in=0;in<100000;in++) {
|
|
w.push_back(2);
|
|
i.push_back(2);
|
|
}
|
|
|
|
NeuralNetwork::BasisFunction::Linear l;
|
|
{
|
|
auto start = std::chrono::high_resolution_clock::now();
|
|
for(int in=0;in<1000;in++) {
|
|
l.compute(w,i);
|
|
}
|
|
auto end = std::chrono::high_resolution_clock::now();
|
|
std::chrono::duration<double> diff = end-start;
|
|
std::cout << "C++ :" << diff.count() << " s\n";
|
|
}
|
|
{
|
|
auto start = std::chrono::high_resolution_clock::now();
|
|
for(int in=0;in<1000;in++) {
|
|
l.computeStreaming(w,i);
|
|
}
|
|
auto end = std::chrono::high_resolution_clock::now();
|
|
std::chrono::duration<double> diff = end-start;
|
|
std::cout << "SSE :" << diff.count() << " s\n";
|
|
}
|
|
*/
|
|
std::cout <<"OK" << std::endl;
|
|
|
|
} |