* @return a new vector with the result of the operation.
*/
protected DoubleVector forward(int fromLayer, DoubleVector intermediateOutput) {
DoubleMatrix weightMatrix = this.weightMatrixList.get(fromLayer);
DoubleVector vec = weightMatrix.multiplyVectorUnsafe(intermediateOutput);
vec = vec.applyToElements(this.squashingFunctionList.get(fromLayer));
// add bias
DoubleVector vecWithBias = new DenseDoubleVector(vec.getDimension() + 1);
vecWithBias.set(0, 1);