cn.centipede.numpy.NDArray.add()

Here are the examples of the java api cn.centipede.numpy.NDArray.add() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

13 Source : LogicalImp.java
with MIT License
from DRL-CASIA

public static double loss(NDArray x, NDArray y, NDArray w) {
    int m = x.shape()[0];
    Activation sigmoid = new Sigmoid();
    NDArray h = sigmoid.forward(np.dot(x, w));
    // np.sum(yMat.T * np.log(hypothesis) + (1 - yMat).T * np.log(1 - hypothesis))
    // yMat.T * np.log(hypothesis)
    NDArray left = y.T().dot(np.log(h));
    NDArray right = (y.negative().add(1)).T().multiply(np.log(h.negative().add(1)));
    NDArray ret = left.add(right);
    double cost = (-1.0 / m) * np.sum(ret);
    return cost;
}