You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hama.apache.org by Thomas Jungblut <th...@gmail.com> on 2012/10/12 09:11:10 UTC

Re: svn commit: r1397446 - /hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java

You need to reopen the input on every peer in your case ;)
To get M you can loop over the data in setup and then reopen again and
exchange the numbers via messaging.

GL!

2012/10/12 <to...@apache.org>

> Author: tommaso
> Date: Fri Oct 12 06:09:56 2012
> New Revision: 1397446
>
> URL: http://svn.apache.org/viewvc?rev=1397446&view=rev
> Log:
> [HAMA-651] - added a couple of TODOs
>
> 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=1397446&r1=1397445&r2=1397446&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
> Fri Oct 12 06:09:56 2012
> @@ -104,7 +104,7 @@ public class GradientDescentBSP extends
>          numRead += costResult.getVector().get(1);
>        }
>
> -      totalCost /= numRead;
> +      totalCost /= numRead; // TODO : remove this and incorporate the 1/m
> element in RegressionModel#calculateCostForItem
>
>        if (cost - totalCost < 0) {
>          throw new RuntimeException("gradient descent failed to converge
> with alpha " + alpha);
> @@ -123,7 +123,9 @@ public class GradientDescentBSP extends
>
>        peer.sync();
>
> -      peer.reopenInput();
> +      if (master) { // TODO : check if this has to be done only by the
> master
> +        peer.reopenInput();
> +      }
>
>        double[] thetaDelta = new double[theta.getLength()];
>
>
>
>

Re: svn commit: r1397446 - /hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java

Posted by Tommaso Teofili <to...@apache.org>.
thanks, nice suggestions :)
Tommaso

2012/10/12 Thomas Jungblut <th...@gmail.com>

> You need to reopen the input on every peer in your case ;)
> To get M you can loop over the data in setup and then reopen again and
> exchange the numbers via messaging.
>
> GL!
>
> 2012/10/12 <to...@apache.org>
>
> > Author: tommaso
> > Date: Fri Oct 12 06:09:56 2012
> > New Revision: 1397446
> >
> > URL: http://svn.apache.org/viewvc?rev=1397446&view=rev
> > Log:
> > [HAMA-651] - added a couple of TODOs
> >
> > 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=1397446&r1=1397445&r2=1397446&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
> > Fri Oct 12 06:09:56 2012
> > @@ -104,7 +104,7 @@ public class GradientDescentBSP extends
> >          numRead += costResult.getVector().get(1);
> >        }
> >
> > -      totalCost /= numRead;
> > +      totalCost /= numRead; // TODO : remove this and incorporate the
> 1/m
> > element in RegressionModel#calculateCostForItem
> >
> >        if (cost - totalCost < 0) {
> >          throw new RuntimeException("gradient descent failed to converge
> > with alpha " + alpha);
> > @@ -123,7 +123,9 @@ public class GradientDescentBSP extends
> >
> >        peer.sync();
> >
> > -      peer.reopenInput();
> > +      if (master) { // TODO : check if this has to be done only by the
> > master
> > +        peer.reopenInput();
> > +      }
> >
> >        double[] thetaDelta = new double[theta.getLength()];
> >
> >
> >
> >
>