remove \r
[extl.git] / extl / intelligence / ann / test / ada_boosting_n_networks_test.h
blob16cf0128fc7dc8cb34899f7fc3373d468af046c4
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: ada_boosting_n_networks_test.h
4 * Created: 09.06.07
5 * Updated: 09.06.07
7 * Brief: Unit-testing
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_INTELLIGENCE_ANN_ADA_BOOSTING_N_NETWORKS_TEST_H
13 #define EXTL_INTELLIGENCE_ANN_ADA_BOOSTING_N_NETWORKS_TEST_H
15 /* ///////////////////////////////////////////////////////////////////////
16 * unit_test namespace
18 EXTL_INTELLIGENCE_BEGIN_WHOLE_NAMESPACE
19 EXTL_TEST_NAME_BEGIN_NAMESPACE(ada_boosting_n_networks_test)
21 /* ///////////////////////////////////////////////////////////////////////
22 * Unit-testing
24 static int ada_boosting_n_networks_test()
26 e_size_t i;
27 /* ///////////////////////////////////////////////////////////////////////
28 * train xor
29 * note: samples size: 4 is so few, maybe no convergence
31 * 0 0 => 0
32 * 0 1 => 1
33 * 1 0 => 1
34 * 1 1 => 0
36 /*EXTL_TEST_TRACE(_T("ada_boosting_n_networks_test: train xor\n"));
37 typedef bp_network<2, 1> xor_bp_type;
38 typedef ada_boosting_n_networks<xor_bp_type> xor_ada_boosting_type;
39 typedef xor_bp_type::layers_type xor_layers_type;
40 xor_bp_type xor_bp_0(xor_layers_type(2), 0.2);
41 xor_bp_type xor_bp_1(xor_layers_type(3), 0.3);
42 xor_bp_type xor_bp_2(xor_layers_type(4), 0.4);
43 xor_bp_type xor_bp_3(xor_layers_type(5), 0.5);
44 xor_bp_type xor_bp_4(xor_layers_type(6), 0.6);
45 xor_ada_boosting_type xor_ada_boosting(&xor_bp_0, &xor_bp_1, &xor_bp_2, &xor_bp_3, &xor_bp_4);
46 EXTL_NS_TEST(xor_tester)<xor_ada_boosting_type> xtr;
47 xtr.test(xor_ada_boosting, 50);*/
49 /* ///////////////////////////////////////////////////////////////////////
50 * train not
51 * note: samples size: 4 is so few, maybe no convergence
53 * 0 0 => 1 1
54 * 0 1 => 1 0
55 * 1 0 => 0 1
56 * 1 1 => 0 0
58 EXTL_TEST_TRACE(_T("ada_boosting_n_networks_test: train not\n"));
59 typedef bp_network<2, 2> not_bp_type;
60 typedef ada_boosting_n_networks<not_bp_type> not_ada_boosting_type;
61 typedef not_bp_type::layers_type not_layers_type;
62 not_ada_boosting_type not_ada_boosting;
64 for (i = 0; i < 10; ++i)
65 not_ada_boosting.push_back(not_bp_type(not_layers_type(10), 0.5));
67 EXTL_NS_TEST(not_tester)<not_ada_boosting_type> ntr;
68 ntr.test(not_ada_boosting, 50);
70 /* ///////////////////////////////////////////////////////////////////////
71 * train sin
72 * [0, 2 * pi]
74 EXTL_TEST_TRACE(_T("ada_boosting_n_networks_test: train sin(0, 2 * pi)\n"));
75 typedef bp_network<8, 8> sin_bp_type;
76 typedef ada_boosting_n_networks<sin_bp_type> sin_ada_boosting_type;
77 typedef sin_bp_type::layers_type sin_layers_type;
78 typedef sin_bp_type::sample_type sin_sample_type;
79 typedef sin_bp_type::samples_type sin_samples_type;
80 sin_ada_boosting_type sin_ada_boosting;
82 // now exists VC6.0 scoped_buffer<> bug
83 for (i = 0; i < 10; ++i)
84 sin_ada_boosting.push_back(sin_bp_type(sin_layers_type(10), 0.5));
86 EXTL_NS_TEST(sin_tester)<sin_ada_boosting_type> str;
87 str.test(sin_ada_boosting, 200, 16);
89 return 0;
91 int ada_boosting_n_networks_test_ret = ada_boosting_n_networks_test();
93 /* ///////////////////////////////////////////////////////////////////////
94 * ::unit_test namespace
96 EXTL_TEST_NAME_END_NAMESPACE(ada_boosting_n_networks_test)
97 EXTL_INTELLIGENCE_END_WHOLE_NAMESPACE
98 /* //////////////////////////////////////////////////////////////////// */
99 #endif /* EXTL_INTELLIGENCE_ANN_ADA_BOOSTING_N_NETWORKS_TEST_H */
100 /* //////////////////////////////////////////////////////////////////// */