Preconditions.checkArgument(this.layerSizeList.get(0) - 1 == instance
.getDimension(), String.format(
"The dimension of input instance should be %d.",
this.layerSizeList.get(0) - 1));
// transform the features to another space
DoubleVector transformedInstance = this.featureTransformer
.transform(instance);
// add bias feature
DoubleVector instanceWithBias = new DenseDoubleVector(
transformedInstance.getDimension() + 1);
instanceWithBias.set(0, 0.99999); // set bias to be a little bit less than
// 1.0
for (int i = 1; i < instanceWithBias.getDimension(); ++i) {
instanceWithBias.set(i, transformedInstance.get(i - 1));
}
List<DoubleVector> outputCache = getOutputInternal(instanceWithBias);
// return the output of the last layer
DoubleVector result = outputCache.get(outputCache.size() - 1);
// remove bias
return result.sliceUnsafe(1, result.getDimension() - 1);
}