remove \r
[extl.git] / extl / intelligence / ann / test / not_tester.h
blobdb866b3755268de5d09beb566e73384e0ba78e44
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: not_tester.h
4 * Created: 08.12.17
5 * Updated: 08.12.17
7 * Brief: Unit-testing tester
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_INTELLIGENCE_ANN_TEST_NOT_TESTER_H
13 #define EXTL_INTELLIGENCE_ANN_TEST_NOT_TESTER_H
15 /* ///////////////////////////////////////////////////////////////////////
16 * ::extl::intelligence::test namespace
18 EXTL_INTELLIGENCE_BEGIN_WHOLE_NAMESPACE
19 EXTL_TEST_BEGIN_NAMESPACE
21 /* not_tester
23 * 0 0 => 1 1
24 * 0 1 => 1 0
25 * 1 0 => 0 1
26 * 1 1 => 0 0
28 template<typename_param_k Net>
29 struct not_tester
31 public:
32 typedef Net network_type;
33 typedef typename_type_k network_type::sample_type sample_type;
34 typedef typename_type_k network_type::samples_type samples_type;
35 typedef typename_type_k network_type::size_type size_type;
36 typedef typename_type_k network_type::float_type float_type;
37 typedef basic_network_validator<network_type> validator_type;
39 public:
40 void test(network_type& network, size_type n)
42 sample_type sp;
43 samples_type sps(4);
44 validator_type validator;
46 sps[0].binput("00");
47 sps[0].breal("11");
49 sps[1].binput("01");
50 sps[1].breal("10");
52 sps[2].binput("10");
53 sps[2].breal("01");
55 sps[3].binput("11");
56 sps[3].breal("00");
58 network.train(sps, n);
60 sp.binput("00");
61 network.run(sp);
62 EXTL_TEST_TRACE(_T("input:%d %d output:%d %d foutput:%f %f"), sp.get_binput(0), sp.get_binput(1), sp.get_boutput(0), sp.get_boutput(1), network.foutput(0), network.foutput(1));
64 sp.binput("01");
65 network.run(sp);
66 EXTL_TEST_TRACE(_T("input:%d %d output:%d %d foutput:%f %f"), sp.get_binput(0), sp.get_binput(1), sp.get_boutput(0), sp.get_boutput(1), network.foutput(0), network.foutput(1));
68 sp.binput("10");
69 network.run(sp);
70 EXTL_TEST_TRACE(_T("input:%d %d output:%d %d foutput:%f %f"), sp.get_binput(0), sp.get_binput(1), sp.get_boutput(0), sp.get_boutput(1), network.foutput(0), network.foutput(1));
72 sp.binput("11");
73 network.run(sp);
74 EXTL_TEST_TRACE(_T("input:%d %d output:%d %d foutput:%f %f"), sp.get_binput(0), sp.get_binput(1), sp.get_boutput(0), sp.get_boutput(1), network.foutput(0), network.foutput(1));
76 validator.validate(network, sps);
77 EXTL_TEST_TRACE(_T("n:%d mse:%f erate:%f\n"), sps.size() * n, validator.mse(), validator.erate());
80 /* ///////////////////////////////////////////////////////////////////////
81 * ::extl::intelligence::test namespace
83 EXTL_TEST_END_NAMESPACE
84 EXTL_INTELLIGENCE_END_WHOLE_NAMESPACE
85 /* //////////////////////////////////////////////////////////////////// */
86 #endif /* EXTL_INTELLIGENCE_ANN_TEST_NOT_TESTER_H */
87 /* //////////////////////////////////////////////////////////////////// */