You probably have a shift solenoid ro converter clutch solenoid that is bad. It all dpends on which gears it is happening in. If it is all it may be the Converter clutch solenoid. If it has been doing this for a while or there is high mileage on the transmission and the fluid has not been chagned regularly, you may have mechanical issues that will require a re-build.
Have the trouble codes pulled to see if anything comes up. Any Advance Auto or Auto Zone will do this for free.