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


Java SimpleMatrix.transpose方法代码示例

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


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

示例1: evaluateMatrices

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
String evaluateMatrices(AdvancedDisplay display) throws SyntaxException {
    try {
        SimpleMatrix matrix = null;
        boolean add = false;
        boolean multiply = false;
        for(int i = 0; i < display.getChildCount(); i++) {
            View child = display.getChildAt(i);
            if(child instanceof MatrixView) {
                if(!add && !multiply) {
                    matrix = ((MatrixView) child).getSimpleMatrix();
                }
                else if(add) {
                    add = false;
                    if(matrix == null) throw new SyntaxException();
                    matrix = matrix.plus(((MatrixView) child).getSimpleMatrix());
                }
                else if(multiply) {
                    multiply = false;
                    if(matrix == null) throw new SyntaxException();
                    matrix = matrix.mult(((MatrixView) child).getSimpleMatrix());
                }
            }
            else if(child instanceof MatrixTransposeView) {
                if(matrix == null) throw new SyntaxException();
                matrix = matrix.transpose();
            }
            else if(child instanceof MatrixInverseView) {
                if(matrix == null) throw new SyntaxException();
                matrix = matrix.invert();
            }
            else {
                String text = child.toString();
                if(text.length() > 1) throw new SyntaxException();
                else if(text.length() == 0) continue;
                if(text.startsWith(String.valueOf(Logic.MUL))) multiply = true;
                else if(text.startsWith(String.valueOf(Logic.PLUS))) add = true;
                else throw new SyntaxException();
            }
        }
        return logic.mBaseModule.updateTextToNewMode(MatrixView.matrixToString(matrix, logic), Mode.DECIMAL, logic.mBaseModule.getMode());
    }
    catch(Exception e) {
        throw new SyntaxException();
    }
}
 
开发者ID:gigabytedevelopers,项目名称:CalcMate,代码行数:46,代码来源:MatrixModule.java

示例2: calcularGradientes

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 *
 * calculamos la derivadas calculamos los gradientes retornamos el costo
 *
 */
@Override
public void calcularGradientes() {
    deltasZero();
    ND = inputBach.numRows();
    SimpleMatrix in;
    SimpleMatrix yObs;
    for (int i = 0; i < ND; i++) {//Aquí debemos paralelizar
        //extraemos la fila y la ponemos vertical
        in = inputBach.extractVector(true, i).transpose();
        yObs = outputBach.extractVector(true, i).transpose();
        
        //obtenemos la salida de todas las capas para ganar tiempo
        List<SimpleMatrix> outputs = net.outputLayers(in);
        //calculamos los delta
        SimpleMatrix yCalc = outputs.get(outputs.size() - 1);
        derivadaOutputLayers(yCalc, yObs);
        derivadaHiddenLayers(outputs);
        

        //calculamos los gradientes
        SimpleMatrix a_t = in.transpose();
        for (int j = 0; j < gradW.size(); j++) {
            SimpleMatrix d = deriv.get(j);
            //calculamos el gradiente
            gradW.set(j, d.mult(a_t));
            gradB.set(j, d);
            //preparamos la entrada para la siguiente 
            a_t = outputs.get(j).transpose();
        }

        for (int j = 0; j < gradW.size(); j++) {
            //agregamos el delta
            deltasW.set(j, deltasW.get(j).plus(gradW.get(j)));
            deltasB.set(j, deltasB.get(j).plus(gradB.get(j)));
        }

    }
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:44,代码来源:SGD.java

示例3: calcularGradientes

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
protected void calcularGradientes() {
    deltasZero();//quitar?
    ND = inputBach.numRows();
    SimpleMatrix in;
    SimpleMatrix yObs;
    for (int i = 0; i < ND; i++) {//Aquí debemos paralelizar
        //extraemos la fila y la ponemos vertical
        in = inputBach.extractVector(true, i).transpose();
        yObs = outputBach.extractVector(true, i).transpose();
        //obtenemos la salida de todas las capas para ganar tiempo
        List<SimpleMatrix> outputs = net.outputLayers(in);
        //calculamos los delta
        SimpleMatrix yCalc = outputs.get(outputs.size() - 1);
        derivadaOutputLayers(yCalc, yObs);
        derivadaHiddenLayers(outputs);

        //calculamos los gradientes
        //la primera entrada corresponde a los datos
        SimpleMatrix a_t = in.transpose();
        for (int j = 0; j < gradW.size(); j++) {
            SimpleMatrix d = deriv.get(j);
            //calculamos el gradiente
            gradW.set(j, d.mult(a_t));
            gradB.set(j, d);
            //preparamos la entrada para la siguiente capa
            a_t = outputs.get(j).transpose();
        }

        for (int j = 0; j < gradW.size(); j++) {
            //agregamos el delta
            deltasW.set(j, deltasW.get(j).plus(gradW.get(j)));
            deltasB.set(j, deltasB.get(j).plus(gradB.get(j)));
        }
    }
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:36,代码来源:Backpropagation.java


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