/** * Returns the smallest value in a vector of doubles. Any values which * are NaN or infinite are ignored. If the vector is empty, 0.0 is * returned. */ public static double safeMin(double[] v) { double[] u = filterNaNAndInfinite(v); if (numRows(u) == 0) return 0.0; return min(u); }
double minD = ArrayMath.min(d); double maxD = ArrayMath.max(d);
@Override protected void takeStep(AbstractStochasticCachingDiffFunction dfunction){ dfunction.returnPreviousValues = true; System.arraycopy(dfunction.HdotVAt(x,v,grad,bSize), 0, Hv, 0, Hv.length); //Update the weights for(int i = 0; i < x.length; i++){ meta = 1-mu*grad[i]*v[i]; if(0.5 > meta){ gains[i] = gains[i]*0.5; }else{ gains[i] = gains[i]*meta; } //Update gain history v[i] = lam*(1+cPosDef*gains[i])*v[i] - gains[i]*(grad[i] + lam*Hv[i]); //Get the next X newX[i] = x[i] - gains[i]*grad[i]; } if(printMinMax){ say("vMin = " + ArrayMath.min(v) + " "); say("vMax = " + ArrayMath.max(v) + " "); say("gainMin = " + ArrayMath.min(gains) + " "); say("gainMax = " + ArrayMath.max(gains) + " "); } }
/** * Returns the largest value in a vector of doubles. Any values which * are NaN or infinite are ignored. If the vector is empty, 0.0 is * returned. */ public static double safeMin(double[] v) { double[] u = filterNaNAndInfinite(v); if (numRows(u) == 0) return 0.0; return min(u); }
/** * Returns the smallest value in a vector of doubles. Any values which * are NaN or infinite are ignored. If the vector is empty, 0.0 is * returned. */ public static double safeMin(double[] v) { double[] u = filterNaNAndInfinite(v); if (numRows(u) == 0) return 0.0; return min(u); }
/** * Returns the smallest value in a vector of doubles. Any values which * are NaN or infinite are ignored. If the vector is empty, 0.0 is * returned. */ public static double safeMin(double[] v) { double[] u = filterNaNAndInfinite(v); if (numRows(u) == 0) return 0.0; return min(u); }
/** * Returns the largest value in a vector of doubles. Any values which * are NaN or infinite are ignored. If the vector is empty, 0.0 is * returned. */ public static double safeMin(double[] v) { double[] u = filterNaNAndInfinite(v); if (numRows(u) == 0) return 0.0; return min(u); }
double minD = ArrayMath.min(d); double maxD = ArrayMath.max(d);
double minD = ArrayMath.min(d); double maxD = ArrayMath.max(d);
double minD = ArrayMath.min(d); double maxD = ArrayMath.max(d);
double minD = ArrayMath.min(d); double maxD = ArrayMath.max(d);
@Override protected void takeStep(AbstractStochasticCachingDiffFunction dfunction){ dfunction.returnPreviousValues = true; System.arraycopy(dfunction.HdotVAt(x,v,grad,bSize), 0, Hv, 0, Hv.length); //Update the weights for(int i = 0; i < x.length; i++){ meta = 1-mu*grad[i]*v[i]; if(0.5 > meta){ gains[i] = gains[i]*0.5; }else{ gains[i] = gains[i]*meta; } //Update gain history v[i] = lam*(1+cPosDef*gains[i])*v[i] - gains[i]*(grad[i] + lam*Hv[i]); //Get the next X newX[i] = x[i] - gains[i]*grad[i]; } if(printMinMax){ say("vMin = " + ArrayMath.min(v) + " "); say("vMax = " + ArrayMath.max(v) + " "); say("gainMin = " + ArrayMath.min(gains) + " "); say("gainMax = " + ArrayMath.max(gains) + " "); } }
@Override protected void takeStep(AbstractStochasticCachingDiffFunction dfunction){ dfunction.returnPreviousValues = true; System.arraycopy(dfunction.HdotVAt(x,v,grad,bSize), 0, Hv, 0, Hv.length); //Update the weights for(int i = 0; i < x.length; i++){ meta = 1-mu*grad[i]*v[i]; if(0.5 > meta){ gains[i] = gains[i]*0.5; }else{ gains[i] = gains[i]*meta; } //Update gain history v[i] = lam*(1+cPosDef*gains[i])*v[i] - gains[i]*(grad[i] + lam*Hv[i]); //Get the next X newX[i] = x[i] - gains[i]*grad[i]; } if(printMinMax){ say("vMin = " + ArrayMath.min(v) + " "); say("vMax = " + ArrayMath.max(v) + " "); say("gainMin = " + ArrayMath.min(gains) + " "); say("gainMax = " + ArrayMath.max(gains) + " "); } }
@Override protected void takeStep(AbstractStochasticCachingDiffFunction dfunction){ dfunction.returnPreviousValues = true; System.arraycopy(dfunction.HdotVAt(x,v,grad,bSize), 0, Hv, 0, Hv.length); //Update the weights for(int i = 0; i < x.length; i++){ meta = 1-mu*grad[i]*v[i]; if(0.5 > meta){ gains[i] = gains[i]*0.5; }else{ gains[i] = gains[i]*meta; } //Update gain history v[i] = lam*(1+cPosDef*gains[i])*v[i] - gains[i]*(grad[i] + lam*Hv[i]); //Get the next X newX[i] = x[i] - gains[i]*grad[i]; } if(printMinMax){ say("vMin = " + ArrayMath.min(v) + " "); say("vMax = " + ArrayMath.max(v) + " "); say("gainMin = " + ArrayMath.min(gains) + " "); say("gainMax = " + ArrayMath.max(gains) + " "); } }