ive seen a few problems with these and not to scare you but usually ends up being replaced with a used transmission, if you have access to a scan tool there is a couple things you can check
1. Monitor the application of the shift solenoids to determine if the Powertrain Control Module (PCM) is actually commanding it to up shift and down shift erratically. If there is no change in the shift solenoid command the transmission may be failing internally. 2. If the PCM is commanding the erratic shifting, check the transmission range switch inputs to the PCM.
this is actually a somewhat common problem ive seen the last few years, if you dont have access to a scan tool we'll have to go another route