DoubleVector activationDifference = activations.subtract(outcome);
// update theta by a smarter sparsity algorithm
Iterator<DoubleVectorElement> featureIterator = feature
.iterateNonZero();
while (featureIterator.hasNext()) {
DoubleVectorElement next = featureIterator.next();
DoubleVector rowVector = theta.getRowVector(next.getIndex());
double l2 = rowVector.pow(2d).sum();
Iterator<DoubleVectorElement> diffIterator = activationDifference
.iterateNonZero();
while (diffIterator.hasNext()) {
DoubleVectorElement diffElement = diffIterator.next();
double val = rowVector.get(diffElement.getIndex());
if (val != 0) {
val = val - diffElement.getValue() * alpha;
// apply the decay
if (lambda != 0d) {
val -= ((lambda * val) + (1d - lambda) * l2);
}
if (Math.abs(val) < nearZeroLimit) {
val = 0;
}
rowVector.set(diffElement.getIndex(), val);
}
}
}
if (verbose && localItems % reportInterval == 0) {
System.out.format(" Item %d | AVG Loss: %f\r", localItems,