本文整理汇总了Java中org.jblas.FloatMatrix.addi方法的典型用法代码示例。如果您正苦于以下问题:Java FloatMatrix.addi方法的具体用法?Java FloatMatrix.addi怎么用?Java FloatMatrix.addi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jblas.FloatMatrix
的用法示例。
在下文中一共展示了FloatMatrix.addi方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import org.jblas.FloatMatrix; //导入方法依赖的package包/类
/**
* Computes the output of the GRU layer
*/
@Override
public void compute(Layer input) {
//Temporary variable to calculate the updateGate, for input x and previous activation h, calculates updateW*x+updateU*h
FloatMatrix updateTemp = this.updateW.mmul(input.output);
updateTemp.addi(this.updateU.mmul(this.output));
updateTemp.addi(this.updateBias);
this.updateGate = this.updateActivation.apply(updateTemp);
// Temporary variable to calculate the resetGate, for input x and previous activation h, calculates resetW*x+resetU*h
FloatMatrix resetTemp = this.resetW.mmul(input.output);
resetTemp.addi(this.resetU.mmul(this.output));
resetTemp.addi(this.resetBias);
this.resetGate = this.resetActivation.apply(resetTemp);
// Temporary variable which holds the linear combination of input and hidden activation to calculate the candidate activation
FloatMatrix candidateActivation = this.hiddenU.mmul(this.resetGate.mul(this.output));
candidateActivation.addi(this.hiddenW.mmul(input.output));
candidateActivation.addi(this.hiddenBias);
// Temporary variable which holds the linear combination of input and candidate activation to calculate the final activation
FloatMatrix outputTemp = this.updateGate.mul(-1);
outputTemp.addi(1);
outputTemp.muli(this.activationFunction.apply(candidateActivation));
this.output = outputTemp.add(this.updateGate.mul(this.output));
}
示例2: apply
import org.jblas.FloatMatrix; //导入方法依赖的package包/类
@Override
public FloatMatrix apply(FloatMatrix input) {
FloatMatrix denom = new FloatMatrix().copy(input);
denom.muli(-1);
MatrixFunctions.expi(denom);
denom.addi(1);
FloatMatrix num = FloatMatrix.ones(denom.rows, denom.columns);
return num.divi(denom);
}