modify register api and add train api