Examples of DoubleMatrix


Examples of fr.soleil.data.container.matrix.DoubleMatrix

                            + attributeName);
                    double[] doubleValues = (double[]) tangoAttribute.readArray(Double.TYPE);
                    int dimX = tangoAttribute.getDimX();
                    int dimY = tangoAttribute.getDimY();
                    if (doubleValues != null && x < dimX && y < dimY) {
                        DoubleMatrix matrix = new DoubleMatrix();
                        matrix.setFlatValue(doubleValues, dimY, dimX);
                        value = matrix.getValueAt(y, x);
                    }
                }
                catch (DevFailed e) {
                    e.printStackTrace();
                }
View Full Code Here

Examples of fr.soleil.data.container.matrix.DoubleMatrix

                    TangoAttribute tangoAttribute = new TangoAttribute(scanServerDeviceName + "/" + attributeName);
                    doubleValues = (double[]) tangoAttribute.readArray(Double.TYPE);
                    int dimX = tangoAttribute.getDimX();
                    int dimY = tangoAttribute.getDimY();
                    if ((doubleValues != null) && (x < dimX) && (y < dimY)) {
                        DoubleMatrix matrix = new DoubleMatrix();
                        matrix.setFlatValue(doubleValues, dimY, dimX);
                        value = matrix.getValueAt(y, x);
                    }
                } catch (DevFailed e) {
                    LOGGER.error("Cannot read {}/{} {}", scanServerDeviceName, attributeName,
                            DevFailedUtils.toString(e));
                    LOGGER.debug("Stack trace", e);
View Full Code Here

Examples of fr.soleil.data.container.matrix.DoubleMatrix

                            + attributeName);
                    double[] doubleValues = (double[]) tangoAttribute.readArray(Double.TYPE);
                    int dimX = tangoAttribute.getDimX();
                    int dimY = tangoAttribute.getDimY();
                    if (doubleValues != null && x < dimX && y < dimY) {
                        DoubleMatrix matrix = new DoubleMatrix();
                        matrix.setFlatValue(doubleValues, dimY, dimX);
                        value = matrix.getValueAt(y, x);
                    }
                }
                catch (DevFailed e) {
                    e.printStackTrace();
                }
View Full Code Here

Examples of fr.soleil.data.container.matrix.DoubleMatrix

        for (int i = 0; i < l; i++) {
            for (int j = 0; j < c; j++) {
                matrixTable[i][j] = Double.valueOf(i * c + j);
            }
        }
        DoubleMatrix result = new DoubleMatrix();
        try {
            result.setValue(matrixTable);
        }
        catch (UnsupportedDataTypeException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
View Full Code Here

Examples of org.apache.hama.commons.math.DoubleMatrix

    for (int i = 0; i < inputInstance.getDimension(); ++i) {
      internalInstance.set(i + 1, inputInstance.get(i));
    }
    DoubleFunction squashingFunction = model
        .getSquashingFunction(inputLayer);
    DoubleMatrix weightMatrix = null;
    if (inputLayer == 0) {
      weightMatrix = this.getEncodeWeightMatrix();
    } else {
      weightMatrix = this.getDecodeWeightMatrix();
    }
    DoubleVector vec = weightMatrix.multiplyVectorUnsafe(internalInstance);
    vec = vec.applyToElements(squashingFunction);
    return vec;
  }
View Full Code Here

Examples of org.apache.hama.commons.math.DoubleMatrix

      int sizePrevLayer = this.layerSizeList.get(layerIdx - 1);
      // row count equals to size of current size and column count equals to
      // size of previous layer
      int row = isFinalLayer ? size : size - 1;
      int col = sizePrevLayer;
      DoubleMatrix weightMatrix = new DenseDoubleMatrix(row, col);
      // initialize weights
      weightMatrix.applyToElements(new DoubleFunction() {
        @Override
        public double apply(double value) {
          return RandomUtils.nextDouble() - 0.5;
        }
View Full Code Here

Examples of org.apache.hama.commons.math.DoubleMatrix

   *
   * @param matrices
   */
  public void updateWeightMatrices(DoubleMatrix[] matrices) {
    for (int i = 0; i < matrices.length; ++i) {
      DoubleMatrix matrix = this.weightMatrixList.get(i);
      this.weightMatrixList.set(i, matrix.add(matrices[i]));
    }
  }
View Full Code Here

Examples of org.apache.hama.commons.math.DoubleMatrix

    // read weights and construct matrices of previous updates
    int numOfMatrices = input.readInt();
    this.weightMatrixList = Lists.newArrayList();
    this.prevWeightUpdatesList = Lists.newArrayList();
    for (int i = 0; i < numOfMatrices; ++i) {
      DoubleMatrix matrix = MatrixWritable.read(input);
      this.weightMatrixList.add(matrix);
      this.prevWeightUpdatesList.add(new DenseDoubleMatrix(
          matrix.getRowCount(), matrix.getColumnCount()));
    }

  }
View Full Code Here

Examples of org.apache.hama.commons.math.DoubleMatrix

   * @param fromLayer The index of the previous layer.
   * @param intermediateOutput The intermediateOutput of previous layer.
   * @return
   */
  protected DoubleVector forward(int fromLayer, DoubleVector intermediateOutput) {
    DoubleMatrix weightMatrix = this.weightMatrixList.get(fromLayer);

    DoubleVector vec = weightMatrix.multiplyVectorUnsafe(intermediateOutput);
    vec = vec.applyToElements(this.squashingFunctionList.get(fromLayer));

    // add bias
    DoubleVector vecWithBias = new DenseDoubleVector(vec.getDimension() + 1);
    vecWithBias.set(0, 1);
View Full Code Here

Examples of org.apache.hama.commons.math.DoubleMatrix

        this.layerSizeList.get(this.layerSizeList.size() - 1));

    DoubleFunction squashingFunction = this.squashingFunctionList
        .get(this.squashingFunctionList.size() - 1);

    DoubleMatrix lastWeightMatrix = this.weightMatrixList
        .get(this.weightMatrixList.size() - 1);
    for (int i = 0; i < deltaVec.getDimension(); ++i) {
      double costFuncDerivative = this.costFunction.applyDerivative(
          labels.get(i), output.get(i + 1));
      // add regularization
      costFuncDerivative += this.regularizationWeight
          * lastWeightMatrix.getRowVector(i).sum();
      deltaVec.set(i, costFuncDerivative);
      deltaVec.set(
          i,
          deltaVec.get(i)
              * squashingFunction.applyDerivative(output.get(i + 1)));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.