示例#1
0
  protected boolean expand(
      int oldRowSize,
      int oldColumnSize,
      int newRowSize,
      int newColumnSize,
      WeightGenerator generator) {
    if (newRowSize < oldRowSize) newRowSize = oldRowSize;
    if (newColumnSize < oldColumnSize) newColumnSize = oldColumnSize;
    boolean expanded = false;

    // expand columns
    if (oldColumnSize < newColumnSize) {
      int i, j, diff = newColumnSize - oldColumnSize, size = oldRowSize * newColumnSize;

      for (i = oldColumnSize; i < size; i += newColumnSize)
        for (j = 0; j < diff; j++) weights.add(i + j, generator == null ? 0 : generator.next());

      setColumnSize(newColumnSize);
      expanded = true;
    }

    // expand label dimension
    if (oldRowSize < newRowSize) {
      int i, size = newRowSize * newColumnSize;
      for (i = weights.size(); i < size; i++) weights.add(generator == null ? 0 : generator.next());

      setRowSize(newRowSize);
      expanded = true;
    }

    return expanded;
  }
示例#2
0
  /** @return a copy of this vector where all the values are initialized to 0. */
  public MajorVector createZeroVector() {
    MajorVector vector = createInstance();

    vector.setSizes(label_size, feature_size);
    vector.weights = new FloatGapList();

    for (int i = 0; i < weights.size(); i++) vector.weights.add(0);

    return vector;
  }
示例#3
0
 public float get(int index) {
   return weights.get(index);
 }
示例#4
0
 @Override
 public String toString() {
   return weights.toString();
 }
示例#5
0
 public int size() {
   return weights.size();
 }
示例#6
0
 public void set(int index, float value) {
   weights.set(index, value);
 }