返回WEIGHTS选项的默认值.

@param sets
@return
764333
public static int[] getDefaultWeights(String... sets) {
		int[] weights = new int[sets.length];
		for (int i = 0; i < sets.length; i++) {
			weights[i] = 1;
		}
		return weights;
	}
1141838
@Override
	public Linear train(InstanceSet trainset, InstanceSet devset) {
		int numSamples = trainset.size();
		System.out.println("Instance Number: "+numSamples);
		float[] hisErrRate = new float[historyNum];

		long beginTime, endTime;
		long beginTimeIter, endTimeIter;
		int iter = 0;
		int frac = numSamples / 10;

		//平均化感知器需要减去的权重
		float[] extraweight = null;
		extraweight = new float[weights.length];
			
		
		beginTime = System.currentTimeMillis();
		
		
		//遍历的总样本数
		int k=0;

		while (iter++ < iternum) {
			if (!simpleOutput) {
				System.out.print("iter "+iter+":  ");
			}
			
			float err = 0;
			float errtot = 0;
			int cnt = 0;
			int cnttot = 0;
			int progress = frac;			

			if (shuffle)
				trainset.shuffle(random);
			
			beginTimeIter = System.currentTimeMillis();
			for (int ii = 0; ii < numSamples; ii++) {
				
				k++;
				Instance inst = trainset.getInstance(ii);
				Predict pred = (Predict) inferencer.getBest(inst,2);				
				
				float l = loss.calc(pred.getLabel(0), inst.getTarget());
				if (l > 0) {
					err += l;
					errtot++;
					update.update(inst, weights, k, extraweight, pred.getLabel(0), c);
					
				}else{
					if (pred.size() > 1)
						update.update(inst, weights, k, extraweight, pred.getLabel(1), c);
				}
				cnt += inst.length();
				cnttot++;				

				if (!simpleOutput && progress != 0 && ii % progress == 0) {
					System.out.print('.');
					progress += frac;
				}				
				
			}//end for

			float curErrRate = err / cnt;

			endTimeIter = System.currentTimeMillis();

			if (!simpleOutput) {
				System.out.println("  time: " + (endTimeIter - beginTimeIter)
						/ 1000.0 + "s");
				System.out.print("Train:");
				System.out.print("  Tag acc: ");
			}
			System.out.print(1 - curErrRate);
			if (!simpleOutput) {
				System.out.print("  Sentence acc: ");
				System.out.print(1 - errtot / cnttot);
				System.out.println();
			}

			System.out.print("Weight Numbers: "
					+ MyArrays.countNoneZero(weights));
			if (innerOptimized) {
				int[] idx = MyArrays.getTop(weights.clone(), threshold, false);
				MyArrays.set(weights, idx, 0.0f);
				System.out.print("	After Optimized: "
						+ MyArrays.countNoneZero(weights));
			}
			System.out.println();

			if (devset != null) {
				evaluate(devset);
			}
			System.out.println();			

			if (interim) {
				Linear p = new Linear(inferencer, af);
				try {
					p.saveTo("tmp.model");
				} catch (IOException e) {
					System.err.println("write model error!");
				}
			}
			hisErrRate[iter%historyNum] = curErrRate;
			if(MyArrays.viarance(hisErrRate) < eps){
				System.out.println("convergence!");
				break;	
			}
			
		}// end while 外循环
		
		//平均化参数
		for (int i = 0; i < weights.length; i++) {
			weights[i] -= extraweight[i]/k;
		}
		
		System.out.print("Non-Zero Weight Numbers: " + MyArrays.countNoneZero(weights));
		if (finalOptimized) {
			int[] idx = MyArrays.getTop(weights.clone(), threshold, false);
			MyArrays.set(weights, idx, 0.0f);
			System.out.print("	After Optimized: "
					+ MyArrays.countNoneZero(weights));
		}
		System.out.println();

		endTime = System.currentTimeMillis();
		System.out.println("time escape:" + (endTime - beginTime) / 1000.0
				+ "s");
		System.out.println();
		Linear p = new Linear(inferencer,af);
		return p;
	}
1297706
public Set<String> keySet() {
        Set<String> keys = new HashSet<String>();
        for (PathSignature path : pathToIndex.keySet())
            keys.add(path.toString());
        return keys;
    }
147644
public final Set<V> getValues(K key) {
	Set<V> set = _getValues(key);
	if(set == null)
	    return Collections.emptySet();
	else 
	    return Collections.unmodifiableSet(set);
    }
1150530
public static <T> Set<T> unmodifiableSet(Set<? extends T> s) {
		return Collections.unmodifiableSet(s);
	}
754171
public Set<String> keySet() {
		// prepare container
		HashSet<String> set = new HashSet<String>();
		// add container keys
		set.addAll(container.keySet());
		// add cache keys
		set.addAll(cache.keySet());
		
		return set;
	}
1213970
public Set<SortedSet<T>> allSupersets(final SortedSet<T> set) {
        final Set<SortedSet<T>> supersets = new LinkedHashSet<>();
        allSupersets(set, this.rootNodes, supersets);
        return supersets;
    }
488951
public static <T> Set<T> nullToEmpty(final Set<T> set) {
        return set == null ? N.<T> emptySet() : set;
    }
304814
public static List<Double> getWeights(ZParams params) {
		Collection<byte[]> collect = params.getParams();
		Iterator<byte[]> iterator = collect.iterator();
		boolean hasWeights = false;
		while (iterator.hasNext()) {
			String value = new String(iterator.next());
			// System.out.println("value:" + value);
			if ("weights".equals(value)) {
				hasWeights = true;
				break;
			}
		}
		if (!hasWeights) {
			return null;
		}
		List<Double> result = new ArrayList<Double>();
		while (iterator.hasNext()) {
			String weight = new String(iterator.next());
			result.add(Double.parseDouble(weight));
		}
		return result;
	}
252775
public static <T> Set<T> intersection(Set<T>... sets) {
		return intersection(Arrays.asList(sets));
	}
1297559
public static <T> Set<T> setOf(T... objects) {
        if (objects == null || objects.length == 0) {
            return Collections.emptySet();
        }
        return new HashSet<>(Arrays.asList(objects));
    }
741357
public static <E> Set<Set<E>> powerSet(Set<E> s) {
    if (s.isEmpty()) {
      Set<Set<E>> h = new HashSet<Set<E>>();
      Set<E> h0 = new HashSet<E>(0);
      h.add(h0);
      return h;
    } else {
      Iterator<E> i = s.iterator();
      E elt = i.next();
      s.remove(elt);
      Set<Set<E>> pow = powerSet(s);
      Set<Set<E>> pow1 = powerSet(s);
      // for (Iterator j = pow1.iterator(); j.hasNext();) {
      for (Set<E> t : pow1) {
        // Set<E> t = new HashSet<E>((Set<E>) j.next());
        t.add(elt);
        pow.add(t);
      }
      s.add(elt);
      return pow;
    }
  }
112119
public double weight() {
        double result = 0;
        Iterator edgeIterator = edgeSet().iterator();
        while (edgeIterator.hasNext()) {
            result += ((Edge) edgeIterator.next()).getWeight();
        }
        return result;
    }
1099761
public static <T> Set<T> toImmutableSet(final Set<? extends T> set) {
    switch (set.size()) {
      case 0:
        return Collections.emptySet();
      case 1:
        return Collections.singleton(set.iterator().next());
      default:
        return Collections.unmodifiableSet(set);
    }
  }
440585
@SuppressWarnings("unchecked")
    private static <T> Set<T> cast(Set<?> set) {
        return (Set<T>)set;
    }
721631
@SuppressWarnings("unchecked")
    @NonNull
    public static Set<String> nonNullSet(@Nullable String[] items) {
        return items == null || items.length == 0
                ? Collections.<String>emptySet()
                : new HashSet<String>(asList(items));
    }
496755
public static <S extends Solution<?>> void weightedProduct(List<S> solutionsList, double[] weights) {
    for (S solution : solutionsList) {
      double product = Math.pow(solution.getObjective(0), weights[0]);
      for (int i = 1; i < solution.getNumberOfObjectives(); i++) {
        product *= Math.pow(solution.getObjective(i), weights[i]);
      }
      setScalarizationValue(solution, product);
    }
  }