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


Java SimpleMatrix.getNumElements方法代码示例

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


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

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

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

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

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

示例5: init

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * Inicializamos una matriz de pesos con las filas y columnas dadas<br>
 * r = sqrt(6)/(sqrt(s + n + 1)) val = 2 * rand * r - r
 *
 * @param matrix inicializada según la forma: sqrt(6)/(sqrt(s + n + 1)) 
 */
@Override
public void init(SimpleMatrix matrix) {
    double r = Math.sqrt(6) / Math.sqrt(matrix.numRows() + matrix.numCols() + 1);
    for (int i = 0; i < matrix.getNumElements(); i++) {
        matrix.set(i, random.nextDouble() * 2 * r - r);
    }
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:14,代码来源:DefaultInit.java

示例6: init

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * <b>Small random numbers</b>: we still want the weights to be very close
 * to zero, but as we have argued above, not identically zero. As a
 * solution, it is common to initialize the weights of the neurons to small
 * numbers and refer to doing so as symmetry breaking. The idea is that the
 * neurons are all random and unique in the beginning, so they will compute
 * distinct updates and integrate themselves as diverse parts of the full
 * network. The implementation for one weight matrix might look like W =
 * 0.01 * random.nextGaussian(), where random samples from a zero mean, unit
 * standard deviation gaussian. With this formulation, every neuron’s weight
 * vector is initialized as a random vector sampled from a multi-dimensional
 * gaussian, so the neurons point in random direction in the input space. It
 * is also possible to use small numbers drawn from a uniform distribution,
 * but this seems to have relatively little impact on the final performance
 * in practice.
 * <br><br>
 * <b>Warning</b>: It’s not necessarily the case that smaller numbers will
 * work strictly better. For example, a Neural Network layer that has very
 * small weights will during backpropagation compute very small gradients on
 * its data (since this gradient is proportional to the value of the
 * weights). This could greatly diminish the “gradient signal” flowing
 * backward through a network, and could become a concern for deep networks.
 * <br><br>
 *
 * see:
 * <url>http://cs231n.github.io/neural-networks-2/#weight-initialization</url>
 *
 * @param matrix
 */
@Override
public void init(SimpleMatrix matrix) {
    for (int i = 0; i < matrix.getNumElements(); i++) {
        matrix.set(i, 0.01 * random.nextGaussian());
    }
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:36,代码来源:SmallRandomInit.java

示例7: init

import org.ejml.simple.SimpleMatrix; //导入方法依赖的package包/类
/**
 * <b>Positive random numbers</b>: we still want the weights to be positive,
 * but between zero and one.
 * <br><br>
 *
 * @param matrix
 */
@Override
public void init(SimpleMatrix matrix) {
    for (int i = 0; i < matrix.getNumElements(); i++) {
        matrix.set(i, random.nextDouble());
    }
}
 
开发者ID:mroodschild,项目名称:froog,代码行数:14,代码来源:PositiveRandomInit.java


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