Github user nzw0301 commented on a diff in the pull request:
https://github.com/apache/incubator-hivemall/pull/111#discussion_r136113122
--- Diff: core/src/main/java/hivemall/recommend/SlimUDTF.java ---
@@ -217,13 +347,48 @@ private void train(int i, Map<?, ?> Ri, Map<?, ?>
topKRatesOfI, int j, Map<?, ?>
double eui = rui - predict(u, i, topKRatesOfI, j);
gradSum += ruj * eui;
rateSum += ruj * ruj;
- errs += eui * eui;
+
+ if (this.numIterations > 1){
+ this.A.unsafeSet((int) u, j, ruj); // need optimize
+ }
}
gradSum /= N;
rateSum /= N;
- errs /= N;
+ this.W.unsafeSet(i, j, getUpdateTerm(gradSum, rateSum));
+ }
+
+
+// private void train(int i, Map<?, ?> Ri, Map<?, ?> topKRatesOfI, int
j, Map<?, ?> Rj) {
+// int N = Rj.size();
+// double gradSum = 0.d;
+// double rateSum = 0.d;
+// double errs = 0.d;
+// for (Map.Entry<?, ?> userRate : Rj.entrySet()) {
+// Object u = userRate.getKey();
+// double ruj =
PrimitiveObjectInspectorUtils.getDouble(userRate.getValue(),
+// this.itemJRateValueOI);
+// double rui = 0.d;
+// if (Ri.containsKey(u)) {
+// rui = PrimitiveObjectInspectorUtils.getDouble(Ri.get(u),
this.itemIRateValueOI);
+// }
+//
+// double eui = rui - predict(u, i, topKRatesOfI, j);
+// gradSum += ruj * eui;
+// rateSum += ruj * ruj;
+// errs += eui * eui;
+// }
+//
+// gradSum /= N;
+// rateSum /= N;
+// errs /= N;
+//
+// this.loss += errs;
+// this.W.unsafeSet(i, j, getUpdateTerm(gradSum, rateSum));
+// }
+
+ private double getUpdateTerm(double gradSum, double rateSum){
--- End diff --
Sorry, I missed an error related this definition.
This function refers class variables `l1` and `l2`, so I will change it to
`getUpdateTerm(final double gradSum, final double rateSum, final double l1,
final double l2)`.
---
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.
---