59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
#include <NeuralNetwork/ActivationFunction/Heaviside.h>
|
|
#include <NeuralNetwork/ActivationFunction/Sigmoid.h>
|
|
#include <NeuralNetwork/ActivationFunction/HyperbolicTangent.h>
|
|
|
|
#include <iostream>
|
|
#include <cassert>
|
|
#include <chrono>
|
|
|
|
union {
|
|
__m128 v; // SSE 4 x float vector
|
|
float a[4]; // scalar array of 4 floats
|
|
} U;
|
|
|
|
int main() {
|
|
{
|
|
NeuralNetwork::ActivationFunction::Heaviside h(1.0);
|
|
assert(h(0.2) == 0);
|
|
assert(h(1.2) == 1);
|
|
}
|
|
|
|
{
|
|
NeuralNetwork::ActivationFunction::Heaviside h(0.7);
|
|
assert(h(0.2) == 0);
|
|
assert(h(0.8) == 1);
|
|
}
|
|
|
|
{
|
|
NeuralNetwork::ActivationFunction::Sigmoid s(0.7);
|
|
assert(s(0.1) > 0.517483);
|
|
assert(s(0.1) < 0.51750);
|
|
|
|
assert(s(10) > 0.998989);
|
|
assert(s(10) < 0.999189);
|
|
}
|
|
{
|
|
NeuralNetwork::ActivationFunction::Sigmoid s(5);
|
|
assert(s(0.1) > 0.622359);
|
|
assert(s(0.1) < 0.622559);
|
|
|
|
assert(s(0.7) > 0.970588);
|
|
assert(s(0.7) < 0.970788);
|
|
}
|
|
{
|
|
NeuralNetwork::ActivationFunction::Sigmoid s(0.7);
|
|
U.a[0]=0.1;
|
|
U.a[1]=10;
|
|
U.v=s(U.v);
|
|
|
|
assert(U.a[0] > 0.517483);
|
|
assert(U.a[0] < 0.51750);
|
|
|
|
assert(U.a[1] > 0.998989);
|
|
assert(U.a[1] < 0.999189);
|
|
}
|
|
|
|
std::cout << "OK" << std::endl;
|
|
|
|
return 0;
|
|
} |