当前位置: 首页>>代码示例>>Java>>正文


Java SimpleMatrix.numRows方法代码示例

本文整理汇总了Java中org.ejml.simple.SimpleMatrix.numRows方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleMatrix.numRows方法的具体用法?Java SimpleMatrix.numRows怎么用?Java SimpleMatrix.numRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ejml.simple.SimpleMatrix的用法示例。


在下文中一共展示了SimpleMatrix.numRows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printMatrix

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
private static String printMatrix(SimpleMatrix mat) {
    StringBuilder buffer = new StringBuilder("[");
    int m = mat.numRows();
    int n = mat.numCols();
    for (int i = 0; i < m; i++) {
        buffer.append('[');
        for (int j = 0; j < n; j++) {
            buffer.append(numToString(mat.get(i, j)));
            if (j != n - 1) buffer.append(',');
        }
        buffer.append(']');
    }
    buffer.append(']');

    return buffer.toString();
}
 
开发者ID:tranleduy2000,项目名称:floating_calc,代码行数:17,代码来源:MatrixModule.java

示例2: matrixToString

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
public static String matrixToString(SimpleMatrix matrix, Logic logic) throws SyntaxException {
    int rows = matrix.numRows();
    int columns = matrix.numCols();
    String input = "[";
    for(int i = 0; i < rows; i++) {
        input += "[";
        for(int j = 0; j < columns; j++) {
            input += logic.evaluate(Double.toString(matrix.get(i, j))) + ",";
        }
        // Remove trailing ,
        input = input.substring(0, input.length() - 1);
        input += "]";
    }
    input += "]";
    return input;
}
 
开发者ID:gigabytedevelopers,项目名称:CalcMate,代码行数:17,代码来源:MatrixView.java

示例3: eval

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
public static SimpleMatrix eval(SimpleMatrix matrix){
    SimpleMatrix aux = new SimpleMatrix(matrix.numRows(), matrix.numCols());
    double max;
    int pos;
    for (int i = 0; i < aux.numRows(); i++) {
        SimpleMatrix row = matrix.extractVector(true, i);
        max = row.get(0);
        pos = 0;
        //inicializamos en 1 ya que el 0 ya fue tomado
        for (int j = 1; j < row.numCols(); j++) {
            if (max < row.get(j)) {
                max = row.get(j);
                //guardamos la posición del mas grande
                pos = j;
            }
        }
        //guardamos en la fila y columna un 1
        aux.set(i, pos, 1);
    }
    return aux;
    
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:23,代码来源:Compite.java

示例4: addScalar

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
static SimpleMatrix addScalar(SimpleMatrix mat, double scalar) {
    SimpleMatrix temp = mat.copy();
    int M = mat.numRows();
    int N = mat.numCols();
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++)
            temp.set(i, j, mat.get(i, j) + scalar);
    }
    return temp;
}
 
开发者ID:tranleduy2000,项目名称:floating_calc,代码行数:11,代码来源:MatrixModule.java

示例5: output

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * de forma matricial: <br>
 * -1 + 2 / (1 + e^(-2 . x))
 *
 * @param x
 * @return
 */
@Override
public SimpleMatrix output(SimpleMatrix x) {
    SimpleMatrix div = x.scale(-2).elementExp().plus(1);
    SimpleMatrix b = new SimpleMatrix(x.numRows(), x.numCols());
    b.set(2);
    return b.elementDiv(div).plus(-1);
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:15,代码来源:Tansig.java

示例6: derivative

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * Función Derivada de la softplus
 *
 * @param z
 * @return 1 / (1 + e^(-z))
 */
@Override
public SimpleMatrix derivative(SimpleMatrix z) {
    SimpleMatrix div = z.scale(-1).elementExp().plus(1);
    SimpleMatrix b = new SimpleMatrix(z.numRows(), z.numCols());
    b.set(1);
    return b.elementDiv(div);
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:14,代码来源:Softplus.java

示例7: output

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * Logsig: <br>
 * 1 / (1 + e^(-a))
 *
 * @param a
 * @return
 */
@Override
public SimpleMatrix output(SimpleMatrix a) {
    SimpleMatrix div = a.scale(-1).elementExp().plus(1);
    SimpleMatrix b = new SimpleMatrix(a.numRows(), a.numCols());
    b.set(1);
    return b.elementDiv(div);
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:15,代码来源:Logsig.java

示例8: output

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
@Override
public SimpleMatrix output(SimpleMatrix z) {
    double parm = 3;
    SimpleMatrix p = new SimpleMatrix(z.numRows(), z.numCols());
    for (int i = 0; i < p.getNumElements(); i++) {
        p.set(i, Math.max(z.get(i), z.get(i) * parm));
    }
    return p;
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:10,代码来源:PreRelu.java

示例9: derivative

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
@Override
public SimpleMatrix derivative(SimpleMatrix a) {
    double parm = 3;
    SimpleMatrix p = new SimpleMatrix(a.numRows(), a.numCols());
    for (int i = 0; i < p.getNumElements(); i++) {
        p.set(i, (a.get(i) >= 0) ? parm : -1);
    }
    return p;
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:10,代码来源:PreRelu.java

示例10: derivative

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * f'(z) = 1
 *
 * @param z
 * @return
 */
@Override
public SimpleMatrix derivative(SimpleMatrix z) {
    SimpleMatrix derivada = new SimpleMatrix(z.numRows(), z.numCols());
    derivada.set(1);
    return derivada;
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:13,代码来源:Purelim.java

示例11: output

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
@Override
public SimpleMatrix output(SimpleMatrix z) {
    SimpleMatrix p = new SimpleMatrix(z.numRows(), z.numCols());
    for (int i = 0; i < p.getNumElements(); i++) {
        p.set(i, Math.max(0, z.get(i)));
    }
    return p;
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:9,代码来源:Relu.java

示例12: derivative

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
@Override
public SimpleMatrix derivative(SimpleMatrix a) {
    SimpleMatrix p = new SimpleMatrix(a.numRows(), a.numCols());
    for (int i = 0; i < p.getNumElements(); i++) {
        p.set(i, (a.get(i) >= 0) ? 1 : 0);
    }
    return p;
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:9,代码来源:Relu.java

示例13: costAll

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * Ingresan matrices donde cada columna representa una característica de salida
 * y cada fila representa un nuevo registro, luego se implementa el mse
 * entre las "y<sub>observadas</sub>"  y las "y<sub>calculadas</sub>" <br>
 * <br>
 * [Y<sub>11</sub>, Y<sub>12</sub>, Y<sub>13</sub>]<br>
 * [Y<sub>21</sub>, Y<sub>22</sub>, Y<sub>23</sub>]<br>
 * [Y<sub>31</sub>, Y<sub>32</sub>, Y<sub>33</sub>]<br>
 * [..., ..., ...]<br>
 * [Y<sub>n1</sub>, Y<sub>n2</sub>, Y<sub>n3</sub>]<br>
 *
 * @param Ycalc
 * @param Yobs
 * @return MSE = ∑[(||(Yobs - Ycalc)||^2)/2]/m 
 */
@Override
public double costAll(SimpleMatrix Ycalc, SimpleMatrix Yobs) {
    SimpleMatrix y = Yobs.minus(Ycalc);
    //elementos al cuadrado, sumamos y realizamos la media
    double sum2 = y.elementMult(y).elementSum();
    return sum2 / (2 * y.numRows());
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:23,代码来源:MSE.java

示例14: costAll

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
     * Ingresan matrices donde cada columna representa una característica de
     * salida y cada fila representa un nuevo registro, luego se implementa el
     * CrossEntropy entre las "y<sub>observadas</sub>" y las
     * "y<sub>calculadas</sub>".<br>
     *
     * <br>
     * [Y<sub>11</sub>, Y<sub>12</sub>, Y<sub>13</sub>]<br>
     * [Y<sub>21</sub>, Y<sub>22</sub>, Y<sub>23</sub>]<br>
     * [Y<sub>31</sub>, Y<sub>32</sub>, Y<sub>33</sub>]<br>
     * [..., ..., ...]<br>
     * [Y<sub>n1</sub>, Y<sub>n2</sub>, Y<sub>n3</sub>]<br>
     *
     * @param Ycalc
     * @param Yobs
     * @return J(Ɵ) = -[∑<sup>m</sup><sub>i = 1</sub> ∑<sup>1</sup><sub>K =
     * 0</sub>
     * (1.{y<sup>(i)</sup> = k} log P(y<sup>(i)</sup> = k | x<sup>(i)</sup>; Ɵ
     * )]
     */
    @Override
    public double costAll(SimpleMatrix Ycalc, SimpleMatrix Yobs) {
        SimpleMatrix y = Ycalc.elementMult(Yobs);
        SimpleMatrix sumCols = new SimpleMatrix(y.numRows(), 1);
        CommonOps.sumRows(y.getMatrix(), sumCols.getMatrix());
        return sumCols.elementLog().elementSum() * -1;

        //SimpleMatrix y = Ycalc.elementMult(Yobs);
//        double[] array = ArrayUtils.removeAllOccurences(y.getMatrix().getData(), 0);
//        y = new SimpleMatrix(1, array.length, true, array);
//        return y.elementLog().elementSum() * -1;
    }
 
开发者ID:mroodschild,项目名称:froog,代码行数:33,代码来源:CrossEntropyLoss.java

示例15: eval

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * los datos ingresados ya deben estar formados de la siguiente manera:<br>
 * <br>
 * [1,0,0]<br>
 * [0,1,0]<br>
 * [0,0,1]<br>
 * [1,0,0]<br>
 * <br>
 * IMPORTANTE: tener presente que solo un valor debe ser 1 y el resto 0.
 *
 * @param calc
 * @param obs
 */
public void eval(SimpleMatrix calc, SimpleMatrix obs) {
    elements = calc.numRows();
    int clases = obs.numCols();
    //Creamos la matriz donde serán guardados los datos
    confusionMatrix = new SimpleMatrix(clases, clases);
    for (int i = 0; i < elements; i++) {
        addValue(getIndex(obs.extractVector(true, i)), getIndex(calc.extractVector(true, i)));
    }
    aciertos = confusionMatrix.extractDiag().elementSum();
    aciertosPorc = aciertos / ((double) elements);
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:25,代码来源:ConfusionMatrix.java


注:本文中的org.ejml.simple.SimpleMatrix.numRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。