remove \r
[extl.git] / extl / intelligence / ann / test / pca_mixed_network_test.h
blobc57854de27ef272f25cc1dbfa0de3e6a3e3ace85
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: pca_mixed_network_test.h
4 * Created: 08.12.17
5 * Updated: 08.12.17
7 * Brief: Unit-testing
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_INTELLIGENCE_ANN_PCA_MIXED_NETWORK_TEST_H
13 #define EXTL_INTELLIGENCE_ANN_PCA_MIXED_NETWORK_TEST_H
15 /* ///////////////////////////////////////////////////////////////////////
16 * unit_test namespace
18 EXTL_INTELLIGENCE_BEGIN_WHOLE_NAMESPACE
19 EXTL_TEST_NAME_BEGIN_NAMESPACE(pca_mixed_network_test)
21 /* ///////////////////////////////////////////////////////////////////////
22 * Unit-testing
24 static int pca_mixed_network_test()
26 /* ///////////////////////////////////////////////////////////////////////
27 * train xor
29 * 0 0 => 0
30 * 0 1 => 1
31 * 1 0 => 1
32 * 1 1 => 0
34 EXTL_TEST_TRACE(_T("pca_mixed_network_test: train xor\n"));
35 typedef bp_network < 2, 1
36 , sample_selector<2, 1>::float_sample_type
37 > xor_bp_type;
38 typedef xor_bp_type::layers_type xor_layers_type;
39 typedef ghia_network<2, 2> xor_pca_type;
40 typedef pca_mixed_network<xor_pca_type, xor_bp_type> xor_pca_mixed_type;
41 xor_pca_mixed_type xor_pca_mixed(xor_pca_type(), xor_bp_type(xor_layers_type(10), 0.5));
42 EXTL_NS_TEST(xor_tester)<xor_pca_mixed_type> xtr;
43 xtr.test(xor_pca_mixed, 50);
45 /* ///////////////////////////////////////////////////////////////////////
46 * train not
48 * 0 0 => 1 1
49 * 0 1 => 1 0
50 * 1 0 => 0 1
51 * 1 1 => 0 0
53 EXTL_TEST_TRACE(_T("pca_mixed_network_test: train not\n"));
54 typedef bp_network < 2, 2
55 , sample_selector<2, 2>::float_sample_type
56 > not_bp_type;
57 typedef not_bp_type::layers_type not_layers_type;
58 typedef ghia_network<2, 2> not_pca_type;
59 typedef pca_mixed_network<not_pca_type, not_bp_type> not_pca_mixed_type;
60 not_pca_mixed_type not_pca_mixed(not_pca_type(), not_bp_type(not_layers_type(10), 0.5));
61 EXTL_NS_TEST(not_tester)<not_pca_mixed_type> ntr;
62 ntr.test(not_pca_mixed, 50);
64 /* ///////////////////////////////////////////////////////////////////////
65 * train sin
66 * [0, 2 * pi]
68 EXTL_TEST_TRACE(_T("pca_mixed_network_test: train sin(0, 2 * pi)\n"));
69 typedef bp_network < 4, 8
70 , sample_selector<4, 8>::float_sample_type
71 > sin_bp_type;
72 typedef sin_bp_type::layers_type sin_layers_type;
73 typedef ghia_network<8, 4> sin_pca_type;
74 typedef pca_mixed_network<sin_pca_type, sin_bp_type> sin_pca_mixed_type;
75 sin_pca_mixed_type sin_pca_mixed(sin_pca_type(), sin_bp_type(sin_layers_type(10), 0.5));
76 EXTL_NS_TEST(sin_tester)<sin_pca_mixed_type> str;
78 clock_counter t;
79 t.begin();
80 str.test(sin_pca_mixed, 100);
81 t.end();
82 printf("%d\n", t.ms());
84 return 0;
86 int pca_mixed_network_test_ret = pca_mixed_network_test();
88 /* ///////////////////////////////////////////////////////////////////////
89 * ::unit_test namespace
91 EXTL_TEST_NAME_END_NAMESPACE(pca_mixed_network_test)
92 EXTL_INTELLIGENCE_END_WHOLE_NAMESPACE
93 /* //////////////////////////////////////////////////////////////////// */
94 #endif /* EXTL_INTELLIGENCE_ANN_PCA_MIXED_NETWORK_TEST_H */
95 /* //////////////////////////////////////////////////////////////////// */