datumbox/datumbox-framework · ElasticNetRegularizer.java
java logo
public static <K> void updateWeights(double l1, double l2, double learningRate, Map<K, Double> weights, Map<K, Double> newWeights) {
        L2Regularizer.updateWeights(l2, learningRate, weights, newWeights);
        L1Regularizer.updateWeights(l1, learningRate, weights, newWeights);
    }
Similar code snippets
1.
datumbox/datumbox-framework · L2Regularizer.java
Match rating: 79.5% · See similar code snippets
java logo
public static <K> void updateWeights(double l2, double learningRate, Map<K, Double> weights, Map<K, Double> newWeights) {
        if(l2 > 0.0) {
            for(Map.Entry<K, Double> e : weights.entrySet()) {
                K column = e.getKey();
                newWeights.put(column, newWeights.get(column) + l2*e.getValue()*(-learningRate));
            }
        }
    }
2.
java logo
public double[] to1D(double[][] weights) {
    double[] newWeights = new double[domainDimension()];
    int index = 0;
    for (int i = 0; i < weights.length; i++) {
      System.arraycopy(weights[i], 0, newWeights, index, weights[i].length);
      index += weights[i].length;
    }
    return newWeights;
  }
3.
alibaba/vlayout · GridLayoutHelper.java
Match rating: 62.24% · See similar code snippets
java logo
public void setWeights(float[] weights) {
        if (weights != null) {
            this.mWeights = Arrays.copyOf(weights, weights.length);
        } else {
            this.mWeights = new float[0];
        }
    }
4.
java logo
protected void scaleWeights(double maxWeight) {
        double sf = 1.0 / maxWeight;
        for (int i = 0; i < weights.size(); i++) {
            weights.set(i, weights.get(i) * sf);
        }
    }
5.
bwaldvogel/liblinear-java · Parameter.java
Match rating: 61.2% · See similar code snippets
java logo
public void setWeights(double[] weights, int[] weightLabels) {
        if (weights == null) throw new IllegalArgumentException("'weight' must not be null");
        if (weightLabels == null || weightLabels.length != weights.length)
            throw new IllegalArgumentException("'weightLabels' must have same length as 'weight'");
        this.weightLabel = copyOf(weightLabels, weightLabels.length);
        this.weight = copyOf(weights, weights.length);
    }
6.
Match rating: 61.14% · See similar code snippets
java logo
public void setColWeights(float[] weights) {
        if (weights != null) {
            this.mColWeights = Arrays.copyOf(weights, weights.length);
        } else {
            this.mColWeights = new float[0];
        }
    }
7.
PeterisP/LVTagger · CRFClassifier.java
Match rating: 61.05% · See similar code snippets
java logo
public int getNumWeights() {
    if (weights == null) return 0;
    int numWeights = 0;
    for (double[] wts : weights) {
      numWeights += wts.length;
    }
    return numWeights;
  }
8.
PeterisP/LVTagger · CRFBiasedClassifier.java
Match rating: 61.0% · See similar code snippets
java logo
void addBiasFeature() {
    if(!featureIndex.contains(BIAS)) {
      featureIndex.add(BIAS);
      double[][] newWeights = new double[weights.length+1][];
      System.arraycopy (weights,0,newWeights,0,weights.length);
      newWeights[weights.length] = new double[classIndex.size()];
      weights = newWeights;
    }
  }
9.
jMetal/jMetal · WeightVectors.java
Match rating: 60.58% · See similar code snippets
java logo
public static double[][] initializeUniformlyInTwoDimensions(double epsilon, int numberOfWeights) {
		double[][] weights = new double[numberOfWeights][2];
		
		int indexOfWeight;
		double w, jump;
		
		jump = (1 - (2 * epsilon)) / (numberOfWeights - 1);
		indexOfWeight = 0;
		
		w = epsilon;
		
		//while(w <= (1-epsilon))
		while (indexOfWeight < numberOfWeights) {
			weights[indexOfWeight][0] = w;
			weights[indexOfWeight][1] = 1 - w;
			
			w = w + jump;
			
			indexOfWeight = indexOfWeight + 1;
		}
		
		return weights;
	}
10.
prestodb/presto · NumericHistogram.java
Match rating: 58.98% · See similar code snippets
java logo
private static double computePenalty(double value1, double value2, double weight1, double weight2)
    {
        double weight = value2 + weight2;
        double squaredDifference = (value1 - weight1) * (value1 - weight1);
        double proportionsProduct = (value2 * weight2) / ((value2 + weight2) * (value2 + weight2));
        return weight * squaredDifference * proportionsProduct;
    }