make auto-encoder class quite generic to encapsulate arbitrary cost functions on the hidden state.