Skip to content

Commit 203630d

Browse files
authored
Upgrade ensmallen 1 14 4 (#10)
* Update ensmallen 1.14.4 * Format news with PR numbers aligning to Ensmallen repo. * Update version * Add changelog entry * Bump R version information
1 parent 401b745 commit 203630d

File tree

10 files changed

+99
-27
lines changed

10 files changed

+99
-27
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2019-05-12 James Balamuta <[email protected]>
2+
3+
* DESCRIPTION (Version, Date): Release 1.14.4
4+
5+
* NEWS.md: Update for Ensmallen release 1.14.4
6+
7+
* inst/include/ensmallen_bits: Upgraded to Ensmallen 1.14.4
8+
* inst/include/ensmallen.hpp: ditto
9+
110
2019-03-09 James Balamuta <[email protected]>
211

312
* DESCRIPTION (Version, Date): Release 1.14.1

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: RcppEnsmallen
22
Title: Header-Only C++ Mathematical Optimization Library for 'Armadillo'
3-
Version: 0.1.14.1.1
3+
Version: 0.1.14.4.1
44
Authors@R: c(
55
person("James Joseph", "Balamuta", email = "[email protected]",
66
role = c("aut", "cre", "cph"),

NEWS.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1+
# RcppEnsmallen 0.1.14.4.1
2+
3+
- Upgraded to ensmallen release 1.14.4 "Difficult Crimp" (2019-05-12)
4+
- Fixes for BigBatchSGD ([#91](https://github.com/mlpack/ensmallen/pull/91)).
5+
- Handle eig_sym() failures correctly ([#100](https://github.com/mlpack/ensmallen/pull/100)).
6+
- SPSA test tolerance fix ([#97](https://github.com/mlpack/ensmallen/pull/97)).
7+
- Minor documentation fixes ([#95](https://github.com/mlpack/ensmallen/pull/95), [#98](https://github.com/mlpack/ensmallen/pull/98)).
8+
- Fix newlines at end of file ([#92](https://github.com/mlpack/ensmallen/pull/92)).
9+
110
# RcppEnsmallen 0.1.14.1.1
211

312
- Upgraded to ensmallen release 1.14.1 "Difficult Crimp" (2019-03-09)
4-
- Fixes for SPSA (#87).
5-
- Optimized CNE and DE (#90). Changed initial population generation
13+
- Fixes for SPSA ([#87](https://github.com/mlpack/ensmallen/pull/87)).
14+
- Optimized CNE and DE ([#90](https://github.com/mlpack/ensmallen/pull/90)). Changed initial population generation
615
in CNE to be a normal distribution about the given starting point,
716
which should accelerate convergence.
8-
- Add DE optimizer (#77).
9-
- Fix for Cholesky decomposition in CMAES (#83).
17+
- Add DE optimizer ([#77](https://github.com/mlpack/ensmallen/pull/77)).
18+
- Fix for Cholesky decomposition in CMAES ([#83](https://github.com/mlpack/ensmallen/pull/83)).
1019

1120
# RcppEnsmallen 0.1.13.0.1
1221

1322
- Upgraded to ensmallen release 1.13.0 "Coronavirus Invasion" (2019-01-14)
14-
- Enhance options for AugLagrangian optimizer (#66).
15-
- Add SPSA optimizer (#69).
23+
- Enhance options for AugLagrangian optimizer ([#66](https://github.com/mlpack/ensmallen/pull/66)).
24+
- Add SPSA optimizer ([#69](https://github.com/mlpack/ensmallen/pull/69)).
1625
- Fix list of contributors.
1726
- Make sure all files end with newlines.
1827
- Reordered SPSA parameters to quiet initialization error surfaced with `-Wreorder`.
@@ -22,12 +31,12 @@
2231
- Upgraded to ensmallen release 1.12.0 "New Year's Party" (2018-12-30)
2332
- Add link to ensmallen PDF to README.md.
2433
- Minor documentation fixes. Remove too-verbose documentation from source for
25-
each optimizer (#61).
26-
- Add FTML optimizer (#48).
27-
- Add SWATS optimizer (#42).
28-
- Add Padam optimizer (#46).
29-
- Add Eve optimizer (#45).
30-
- Add ResetPolicy() to SGD-like optimizers (#60).
34+
each optimizer ([#61](https://github.com/mlpack/ensmallen/pull/61)).
35+
- Add FTML optimizer ([#48](https://github.com/mlpack/ensmallen/pull/48)).
36+
- Add SWATS optimizer ([#42](https://github.com/mlpack/ensmallen/pull/42)).
37+
- Add Padam optimizer ([#46](https://github.com/mlpack/ensmallen/pull/46)).
38+
- Add Eve optimizer ([#45](https://github.com/mlpack/ensmallen/pull/45)).
39+
- Add ResetPolicy() to SGD-like optimizers ([#60](https://github.com/mlpack/ensmallen/pull/60)).
3140
- Updated citation information
3241

3342
# RcppEnsmallen 0.1.11.1.1

cran-comments.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Test environments
22

3-
* local OS X install, R 3.5.2
4-
* ubuntu 14.04 (on travis-ci), R 3.5.2
3+
* local OS X install, R 3.6.0
4+
* ubuntu 14.04 (on travis-ci), R 3.6.0
55
* win-builder (devel and release)
66

77
## R CMD check results

inst/include/ensmallen_bits/bigbatch_sgd/adaptive_stepsize.hpp

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AdaptiveStepsize
4848
* @param searchParameter The backtracking search parameter for each
4949
* iteration.
5050
*/
51-
AdaptiveStepsize(const double backtrackStepSize = 0.1,
51+
AdaptiveStepsize(const double backtrackStepSize = 0.5,
5252
const double searchParameter = 0.1) :
5353
backtrackStepSize(backtrackStepSize),
5454
searchParameter(searchParameter)
@@ -73,9 +73,9 @@ class AdaptiveStepsize
7373
void Update(DecomposableFunctionType& function,
7474
double& stepSize,
7575
arma::mat& iterate,
76-
const arma::mat& gradient,
77-
const double gradientNorm,
78-
const double sampleVariance,
76+
arma::mat& gradient,
77+
double& gradientNorm,
78+
double& sampleVariance,
7979
const size_t offset,
8080
const size_t batchSize,
8181
const size_t backtrackingBatchSize,
@@ -87,6 +87,55 @@ class AdaptiveStepsize
8787
// Update the iterate.
8888
iterate -= stepSize * gradient;
8989

90+
// Update Gradient & calculate curvature of quadratic approximation.
91+
arma::mat functionGradient(iterate.n_rows, iterate.n_cols);
92+
arma::mat gradPrevIterate(iterate.n_rows, iterate.n_cols);
93+
arma::mat functionGradientPrev(iterate.n_rows, iterate.n_cols);
94+
95+
double vB = 0;
96+
arma::mat delta0, delta1;
97+
98+
// Initialize previous iterate, if not already initialized.
99+
if (iteratePrev.is_empty())
100+
{
101+
iteratePrev.zeros(iterate.n_rows, iterate.n_cols);
102+
}
103+
104+
// Compute the stochastic gradient estimation.
105+
function.Gradient(iterate, offset, gradient, 1);
106+
function.Gradient(iteratePrev, offset, gradPrevIterate, 1);
107+
108+
delta1 = gradient;
109+
110+
for (size_t j = 1, k = 1; j < backtrackingBatchSize; ++j, ++k)
111+
{
112+
function.Gradient(iterate, offset + j, functionGradient, 1);
113+
delta0 = delta1 + (functionGradient - delta1) / k;
114+
115+
// Compute sample variance.
116+
vB += arma::norm(functionGradient - delta1, 2.0) *
117+
arma::norm(functionGradient - delta0, 2.0);
118+
119+
delta1 = delta0;
120+
gradient += functionGradient;
121+
122+
// Used for curvature calculation.
123+
function.Gradient(iteratePrev, offset + j, functionGradientPrev, 1);
124+
gradPrevIterate += functionGradientPrev;
125+
}
126+
127+
// Update sample variance & norm of the gradient.
128+
sampleVariance = vB;
129+
gradientNorm = std::pow(arma::norm(gradient / backtrackingBatchSize, 2), 2.0);
130+
131+
// Compute curvature.
132+
double v = arma::trace(arma::trans(iterate - iteratePrev) *
133+
(gradient - gradPrevIterate)) /
134+
std::pow(arma::norm(iterate - iteratePrev, 2), 2.0);
135+
136+
// Update previous iterate.
137+
iteratePrev = iterate;
138+
90139
// TODO: Develop an absolute strategy to deal with stepSizeDecay updates in
91140
// case we arrive at local minima. See #1469 for more details.
92141
double stepSizeDecay = 0;
@@ -95,11 +144,11 @@ class AdaptiveStepsize
95144
if (batchSize < function.NumFunctions())
96145
{
97146
stepSizeDecay = (1 - (1 / ((double) batchSize - 1) * sampleVariance) /
98-
(batchSize * gradientNorm)) / batchSize;
147+
(batchSize * gradientNorm)) / v;
99148
}
100149
else
101150
{
102-
stepSizeDecay = 1 / function.NumFunctions();
151+
stepSizeDecay = 1 / v;
103152
}
104153
}
105154

@@ -153,7 +202,7 @@ class AdaptiveStepsize
153202
backtrackingBatchSize);
154203

155204
while (overallObjectiveUpdate >
156-
(overallObjective + searchParameter * stepSize * gradientNorm))
205+
(overallObjective - searchParameter * stepSize * gradientNorm))
157206
{
158207
stepSize *= backtrackStepSize;
159208

@@ -163,6 +212,9 @@ class AdaptiveStepsize
163212
}
164213
}
165214

215+
//! Last function parameters value.
216+
arma::mat iteratePrev;
217+
166218
//! The backtracking step size for each iteration.
167219
double backtrackStepSize;
168220

inst/include/ensmallen_bits/bigbatch_sgd/backtracking_line_search.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class BacktrackingLineSearch
8989
offset, backtrackingBatchSize);
9090

9191
while (overallObjectiveUpdate >
92-
(overallObjective + searchParameter * stepSize * gradientNorm))
92+
(overallObjective - searchParameter * stepSize * gradientNorm))
9393
{
9494
stepSize /= 2;
9595

inst/include/ensmallen_bits/ens_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// The minor version is two digits so regular numerical comparisons of versions
1717
// work right. The first minor version of a release is always 10.
1818
#define ENS_VERSION_MINOR 14
19-
#define ENS_VERSION_PATCH 1
19+
#define ENS_VERSION_PATCH 4
2020
// If this is a release candidate, it will be reflected in the version name
2121
// (i.e. the version name will be "RC1", "RC2", etc.). Otherwise the version
2222
// name will typically be a seemingly arbitrary set of words that does not

inst/include/ensmallen_bits/fw/atoms.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Atoms
8989
// Solve for current gradient.
9090
arma::mat x;
9191
RecoverVector(x);
92-
arma::mat gradient(size(x));
92+
arma::mat gradient(arma::size(x));
9393
function.Gradient(x, gradient);
9494

9595
// Find possible atom to be deleted.

inst/include/ensmallen_bits/sdp/primal_dual_impl.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ Alpha(const arma::mat& A, const arma::mat& dA, double tau, double& alpha)
132132
return false;
133133
// TODO(stephentu): We only want the top eigenvalue, we should
134134
// be able to do better than full eigen-decomposition.
135-
const arma::vec evals = arma::eig_sym(-Linv * dA * Linv.t());
135+
arma::vec evals;
136+
if (!arma::eig_sym(evals, -Linv * dA * Linv.t()))
137+
return false;
138+
136139
const double alphahatinv = evals(evals.n_elem - 1);
137140
double alphahat = 1. / alphahatinv;
138141
if (alphahat < 0.)

inst/include/ensmallen_bits/sgdr/cyclical_decay.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ namespace ens {
2727
*
2828
* @code
2929
* @article{Loshchilov2016,
30-
* title = {Learning representations by back-propagating errors},
3130
* author = {Ilya Loshchilov and Frank Hutter},
3231
* title = {{SGDR:} Stochastic Gradient Descent with Restarts},
3332
* journal = {CoRR},

0 commit comments

Comments
 (0)