nearest neighbors backpropagation equations--need to check gradient