Author: tommaso
Date: Tue Oct 9 07:22:46 2012
New Revision: 1395878
URL: http://svn.apache.org/viewvc?rev=1395878&view=rev
Log:
[HAMA-651] - added theta/cost writedown on cleanup
Modified:
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java
Modified:
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java
URL:
http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java?rev=1395878&r1=1395877&r2=1395878&view=diff
==============================================================================
---
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java
(original)
+++
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java
Tue Oct 9 07:22:46 2012
@@ -160,11 +160,11 @@ public class GradientDescentBSP extends
theta = new DenseDoubleVector(newTheta);
if (log.isInfoEnabled()) {
- log.info("new theta for cost " + totalCost + " is " +
theta.toArray().toString());
+ log.info("new theta for cost " + cost + " is " +
theta.toArray().toString());
}
// master writes down the output
if (master) {
- peer.write(new VectorWritable(theta), new DoubleWritable(totalCost));
+ peer.write(new VectorWritable(theta), new DoubleWritable(cost));
}
}
peer.sync();
@@ -173,6 +173,17 @@ public class GradientDescentBSP extends
}
+ @Override
+ public void cleanup(BSPPeer<VectorWritable, DoubleWritable, VectorWritable,
DoubleWritable, VectorWritable> peer) throws IOException {
+ if (log.isInfoEnabled()) {
+ log.info("computation finished with cost " + cost + " for theta " +
theta);
+ }
+ // master writes down the final output
+ if (master) {
+ peer.write(new VectorWritable(theta), new DoubleWritable(cost));
+ }
+ }
+
public void getTheta(BSPPeer<VectorWritable, DoubleWritable, VectorWritable,
DoubleWritable, VectorWritable> peer) throws IOException, SyncException,
InterruptedException {
if (master && theta == null) {
int size = getXSize(peer);