本文整理汇总了Java中org.jblas.DoubleMatrix.sub方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix.sub方法的具体用法?Java DoubleMatrix.sub怎么用?Java DoubleMatrix.sub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jblas.DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix.sub方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateDeltas
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
private void calculateDeltas(DoubleMatrix expected, DoubleMatrix actual) {
double error1 = expected.getColumn(0).sum();
double error2 = actual.getColumn(0).sum();
double error3 = error1 - error2;
double error4 = Math.pow(error3, 2);
double error5 = 0.5 * error4;
//System.out.println("error : " + error5);
totalError += error5;
if (timestep % 2001 == 0 && timestep != 0) {
totalError = totalError / 2001;
logger.log(Level.INFO, "Error: {0}", totalError);
totalError = 0;
}
//System.out.println("Expected : " + expected.getColumn(0));
//System.out.println("Actual : " + actual.getColumn(0));
deltas[deltas.length - 1] = actual.sub(expected); //Output layer delta
for (int i = weights.length - 1; i >= 1; i--) { //Hidden layer deltas
deltas[i-1] = weights[i].transpose().mmul(deltas[i]).mul(Util.tanhDerivate(layers[i]));
}
}
示例2: doFiniteSizeCorrections
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
private void doFiniteSizeCorrections(Node alphaNode, DoubleMatrix pAlpha) {
DoubleMatrix p, AminusP;
int numExtant = stateProbabilities.getNumExtant();
int alphaIdx = stateProbabilities.getLineageIndex(alphaNode.getNr());
DoubleMatrix A = stateProbabilities.getLineageStateSum();
double sum;
// traverse all extant lineages
for(int lineIdx=0; lineIdx < numExtant; lineIdx++) {
if (lineIdx!=alphaIdx) {
p = stateProbabilities.getStateProbsFromIndex(lineIdx);
AminusP = A.sub(p);
AminusP.maxi(1e-12);
// rterm = p_a / clamp(( A - p_u), 1e-12, INFINITY );
DoubleMatrix rterm = pAlpha.div(AminusP);
//rho = A / clamp(( A - p_u), 1e-12, INFINITY );
DoubleMatrix rho = A.div(AminusP);
//lterm = dot( rho, p_a); //
double lterm = rho.dot(pAlpha);
//p_u = p_u % clamp((lterm - rterm), 0., INFINITY) ;
rterm.rsubi(lterm);
//rterm.subi(lterm);
//rterm.muli(-1);
rterm.maxi(0.0);
// p = p.muli(rterm);
sum = p.dot(rterm);
if (sum > 0) { // update p
p.muli(rterm); // in-place element-wise multiplication,
p.divi(sum); // in-pace normalisation
}
}
}
}
示例3: range_normalization
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public static List<DoubleMatrix> range_normalization(double[] min, double[] max, List<DoubleMatrix> data_list)
{
DoubleMatrix minVector = new DoubleMatrix(min);
DoubleMatrix maxVector = new DoubleMatrix(max);
DoubleMatrix range = maxVector.sub(minVector);
for(DoubleMatrix data : data_list)
{
data.divi(range);
}
return data_list;
}
示例4: tanhDerivate
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
protected static DoubleMatrix tanhDerivate(DoubleMatrix x) {
if (x != null) {
DoubleMatrix ones = DoubleMatrix.ones(x.rows, x.columns);
return ones.sub(x.mul(x));
}
return null;
}