I'm Neal and I am here to assist you. Only accept when you are happy with my assistance. If I can't help I will open your Question to other experts.
You are looking at a solenoid issue or a computer issue, most likely a solenoid problem as it is common for them to be intermittant. It could be a shift solenoid or a pressure solenoid based on your symptoms. I will take a diagnostic by a transmission shop to narrow it down for sure.
Here are the locations.