Github user myui commented on a diff in the pull request:
https://github.com/apache/incubator-hivemall/pull/66#discussion_r111728528
--- Diff: core/src/main/java/hivemall/topicmodel/OnlineLDAModel.java ---
@@ -350,66 +348,80 @@ private float computeApproxBoundForMiniBatch() {
float score = 0.f;
// prepare
- final float[] gammaSum = new float[_miniBatchSize];
- for (int d = 0; d < gammaSum.length; d++) {
- gammaSum[d] += MathUtils.sum(_gamma[d], _K);
+ float[] gammaSum = new float[_miniBatchSize];
+ Arrays.fill(gammaSum, 0.f);
+ for (int d = 0; d < _miniBatchSize; d++) {
+ for (int k = 0; k < _K; k++) {
+ gammaSum[d] += _gamma[d][k];
+ }
}
- final float[] lambdaSum = new float[_K];
- for (float[] lambda_l : _lambda.values()) {
- MathUtils.add(lambdaSum, lambda_l, _K);
+ float[] lambdaSum = new float[_K];
+ Arrays.fill(lambdaSum, 0.f);
+ for (int k = 0; k < _K; k++) {
+ for (String label : _lambda.keySet()) {
--- End diff --
can be revised to
```java
for(float[] lambda: _lambda.values()) {
MathUtils.add(lambdaSum, lambda, _K);
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---