updated with implementation of decoding for perceptron