Fast and Efficient Locomotion via Learned Gait Transitions