Instead of invisible fence, I encourage you to train your dog to the "come" command. You can use the wireless remote that comes with most invisible fence kits to do this. Let the dog out, when he/she goes beyond your boundary, yell "come". If there's no response, use the warning beep on the remote. That's usually all it takes. The beep is uncomfortable enough. If the beep doesn't work, yell "come" again, if no response, then issue a shock.
I trained my poodle this way, and it literally only took one shock for him to respond to come his entire life.
I learned this from a dog trainer with 25 years experience. If you don't have the wireless remote, you can shake a coffee can full of pennies, it has a similar effect.