First question is the fluid level full? and what is the condition of the fluid is it brown or smell burnt? This problem can be as simple as needing to add fluid or changing the filter and fluid. It could also be more severe, and may require full diag. and a trip to the shop.
Don't sound like a solenoid problem because it is all gears, both up and down shifting. and only sometime. Sounds more like fluid and filter problem that causes vales to stick or not get enough pressure to work right. Good Luck, lets hope for the best! deal with the rest.