Threshold Based Encoding And Learning