forked from mlpack/ensmallen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
katyusha_test.cpp
105 lines (95 loc) · 3.12 KB
/
katyusha_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* @file katyusha_test.cpp
* @author Marcus Edel
* @author Conrad Sanderson
*
* ensmallen is free software; you may redistribute it and/or modify it under
* the terms of the 3-clause BSD license. You should have received a copy of
* the 3-clause BSD license along with ensmallen. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#include <ensmallen.hpp>
#include "catch.hpp"
#include "test_function_tools.hpp"
using namespace ens;
using namespace ens::test;
/**
* Run Katyusha on logistic regression and make sure the results are acceptable.
*/
TEST_CASE("KatyushaLogisticRegressionTest", "[KatyushaTest]")
{
// Run with a couple of batch sizes.
for (size_t batchSize = 30; batchSize < 45; batchSize = 5)
{
Katyusha optimizer(1.0, 10.0, batchSize, 100, 0, 1e-10, true);
LogisticRegressionFunctionTest(optimizer, 0.015, 0.015);
}
}
/**
* Run Proximal Katyusha on logistic regression and make sure the results are
* acceptable.
*/
TEST_CASE("KatyushaProximalLogisticRegressionTest", "[KatyushaTest]")
{
// Run with a couple of batch sizes.
for (size_t batchSize = 30; batchSize < 45; batchSize = 5)
{
KatyushaProximal optimizer(1.0, 10.0, batchSize, 100, 0, 1e-10, true);
LogisticRegressionFunctionTest(optimizer, 0.015, 0.015);
}
}
/**
* Run Katyusha on logistic regression and make sure the results are acceptable.
* Use arma::fmat.
*/
TEST_CASE("KatyushaLogisticRegressionFMatTest", "[KatyushaTest]")
{
// Run with a couple of batch sizes.
for (size_t batchSize = 30; batchSize < 45; batchSize = 5)
{
Katyusha optimizer(1.0, 10.0, batchSize, 100, 0, 1e-10, true);
LogisticRegressionFunctionTest<arma::fmat>(optimizer, 0.015, 0.015);
}
}
/**
* Run Proximal Katyusha on logistic regression and make sure the results are
* acceptable. Use arma::fmat.
*/
TEST_CASE("KatyushaProximalLogisticRegressionFMatTest", "[KatyushaTest]")
{
// Run with a couple of batch sizes.
for (size_t batchSize = 30; batchSize < 45; batchSize = 5)
{
KatyushaProximal optimizer(1.0, 10.0, batchSize, 100, 0, 1e-10, true);
LogisticRegressionFunctionTest<arma::fmat>(optimizer, 0.015, 0.015);
}
}
#if ARMA_VERSION_MAJOR > 9 ||\
(ARMA_VERSION_MAJOR == 9 && ARMA_VERSION_MINOR >= 400)
/**
* Run Katyusha on logistic regression and make sure the results are acceptable.
* Use arma::sp_mat.
*/
TEST_CASE("KatyushaLogisticRegressionSpMatTest", "[KatyushaTest]")
{
// Run with a couple of batch sizes.
for (size_t batchSize = 30; batchSize < 45; batchSize = 5)
{
Katyusha optimizer(1.0, 10.0, batchSize, 100, 0, 1e-10, true);
LogisticRegressionFunctionTest<arma::sp_mat>(optimizer, 0.015, 0.015);
}
}
/**
* Run Proximal Katyusha on logistic regression and make sure the results are
* acceptable. Use arma::sp_mat.
*/
TEST_CASE("KatyushaProximalLogisticRegressionSpMatTest", "[KatyushaTest]")
{
// Run with a couple of batch sizes.
for (size_t batchSize = 30; batchSize < 45; batchSize = 5)
{
KatyushaProximal optimizer(1.0, 10.0, batchSize, 100, 0, 1e-10, true);
LogisticRegressionFunctionTest<arma::sp_mat>(optimizer, 0.015, 0.015);
}
}
#endif