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


Java SimpleMatrix.numCols方法代码示例

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


在下文中一共展示了SimpleMatrix.numCols方法的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: 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

示例4: 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

示例5: outputZ

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 *
 * @param W W[neuronas x entrada]
 * @param a a[entrada x 1]
 * @param B B[neuronas x 1]
 * @return
 */
@Override
public SimpleMatrix outputZ(SimpleMatrix W, SimpleMatrix a, SimpleMatrix B) {
    //return W.mult(a).plus(B);
    //return W.mult(a).plus(B);
    SimpleMatrix aux = W.mult(a);
    for (int i = 0; i < aux.numCols(); i++) {
        aux.setColumn(i, 0, aux.extractVector(false, i).plus(B).getMatrix().getData());
    }
    return aux;
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:18,代码来源:Tansig.java

示例6: outputZ

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
@Override
    public SimpleMatrix outputZ(SimpleMatrix W, SimpleMatrix a, SimpleMatrix B) {
//        return W.mult(a).plus(B);
        SimpleMatrix aux = W.mult(a);
        for (int i = 0; i < aux.numCols(); i++) {
            aux.setColumn(i, 0, aux.extractVector(false, i).plus(B).getMatrix().getData());
        }
        return aux;
    }
 
开发者ID:mroodschild,项目名称:froog,代码行数:10,代码来源:Softplus.java

示例7: 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

示例8: 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

示例9: outputZ

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * 
 * @param W W[neuronas x entrada]
 * @param a a[entrada x 1]
 * @param B B[neuronas x 1]
 * @return 
 */
@Override
public SimpleMatrix outputZ(SimpleMatrix W, SimpleMatrix a, SimpleMatrix B) {
    //return W.mult(a).plus(B);
    SimpleMatrix aux = W.mult(a);
    for (int i = 0; i < aux.numCols(); i++) {
        aux.setColumn(i, 0, aux.extractVector(false, i).plus(B).getMatrix().getData());
    }
    return aux;
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:17,代码来源:Logsig.java

示例10: output

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
     *
     * la salida será:<br>
     * <table>
     * <tr><td></td><td>[ 1
     * ]</td><td></td><td>[e<sup>(z<sub>1</sub>)</sup>]</td></tr>
     * <tr><td>a =
     * </td><td>------</td><td>*</td><td>[e<sup>(z<sub>2</sub>)</sup>]</td></tr>
     * <tr><td></td><td>&sum(e<sup>zi</sup>)</td><td></td><td>[e<sup>(z<sub>3</sub>)</sup>]</td></tr>
     * </table>
     *
     * @param z
     * @return
     */
    @Override
    public SimpleMatrix output(SimpleMatrix z) {
//        SimpleMatrix p = z.elementExp();
//        double sum = p.elementSum();
//        return p.divide(sum);
        SimpleMatrix p = z.elementExp();
        SimpleMatrix sum = new SimpleMatrix(1, p.numCols());
        CommonOps.sumCols(p.getMatrix(), sum.getMatrix());
        for (int i = 0; i < p.numCols(); i++) {
            p.setColumn(i, 0, p.extractVector(false, i).
                    divide(sum.get(i)).getMatrix().getData());
        }
        return p;
    }
 
开发者ID:mroodschild,项目名称:froog,代码行数:29,代码来源:Softmax.java

示例11: 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

示例12: 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

示例13: outputZ

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
@Override
    public SimpleMatrix outputZ(SimpleMatrix W, SimpleMatrix a, SimpleMatrix B) {
//        return W.mult(a).plus(B);
        //return W.mult(a).plus(B);
        SimpleMatrix aux = W.mult(a);
        for (int i = 0; i < aux.numCols(); i++) {
            aux.setColumn(i, 0, aux.extractVector(false, i).plus(B).getMatrix().getData());
        }
        return aux;
    }
 
开发者ID:mroodschild,项目名称:froog,代码行数:11,代码来源:Purelim.java

示例14: 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

示例15: 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


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