implement rae; note buffer in apply() should be recorded in a inverse manner to backpropagation()