In some cases, this issue is caused by a hardware fault. A loose connection, a short circuit, or a microscopic break in a solder joint may open and close depending on temperature, making the failure intermittent.
Test after taking each of the following steps that you haven't already taken. Back up all data before making any changes.
1. If you can connect to the Internet via Ethernet, Bluetooth, or a USB network device, make sure all available OS X updates are installed. If Wi-Fi is your only means of network access, skip this step.
2.. There are a few reports that the problem was solved by unchecking the box marked
Wake for Wi-Fi network access
in the Power Adapter tab of the Energy Saver preference pane. I can't confirm.
3. Reset the NVRAM.
4. Reset the System Management Controller.
5. Start up in Recovery mode. In the menu bar of the OS X Utilities screen, there's a Wi-Fi menu. Try to connect. If it works, select Install OS X. If your Mac was upgraded from an older version of OS X, you’ll need the Apple ID and password you used to upgrade, so make a note of those before you begin.
6. Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.