22 lines
436 B
C++
22 lines
436 B
C++
#include <NeuralNetwork/FeedForward/Perceptron.h>
|
|
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Weffc++"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
TEST(Perceptron,Test) {
|
|
NeuralNetwork::FeedForward::Perceptron p(2,1);
|
|
|
|
p[1].weight(0)=-1.0;
|
|
p[1].weight(1)=1.001;
|
|
|
|
float ret =p.computeOutput({1,1})[0];
|
|
ASSERT_EQ(ret, 1.0);
|
|
|
|
p[1].weight(1)=0.999;
|
|
ret =p.computeOutput({1,1})[0];
|
|
ASSERT_EQ(ret, 0.0);
|
|
} |