Here is what should be your simple fix, especially if when you reboot the router it works again.
Either in your router settings assign the apple TV's a fixed ip address. If you are not familiar with that process then another fix is in the apple TV settings. In the net work settings, select manual set up. Change the digits after the last . in the ip address to a higher number. For example instead of .3 make it .35.
What is happening is this, as other mobil devises are connecting to your wifi as they enter your range the router assigns them an ip address automatically. Normally it uses the lowest available number. If the ATV is asleep the number it last used is available and can get assigned to your iPad or what ever. When you wake the ATV it either can't connect or connects for a short time as the router tries to fix the conflict.
I run two ATV's plus iPad,iPhone iTouch and none ever drop the connection once I assigned them the ip addresses. Noticed the problem when the two kids would come over and connect to our WiFi, that is when the home sharing would drop. Their mobils were grabbing the sleeping ATV ip's. Once assigned to the devise by the router it holds them for their devises for about 24 hours. That is why it seems so intermittent and is making you crazy!!