Implementing a variable multilayer perceptron from scratch