macOS 10.12.4 keeps losing Wi-Fi connection
I would totally remove your Wi-Fi service, restart, and add your Wi-Fi service back.

To do this:


Go to Apple > System Preferences > Network
Select the Wi-Fi service on the left-hand side
Click on the cog icon at bottom-left and select Make Service Inactive
Now delete the service by clicking on the minus sign (i.e. the - button) at left of the cog
Click on the Apply button
Exit Network preferences
Restart your MBP
Go to Apple > System Preferences > Network
Click on the plus sign (i.e. the + button) at left of the cog
In the pop-up window, ensure that Wi-Fi is selected from the drop-down menu
Click on the Create button
Make sure Wi-Fi is on and connected (it should remember your previous settings, but if not just re-add your Wi-Fi network again)


Let me know if this resolves the issue.

Boot into Safe Mode 

Since removing the Wi-Fi service etc didn't work, let's try booting your Mac into Safe Mode: 


Fully shut down your Mac 
Restart your Mac 
Immediately press the Shift key and keep it down 
Let go of the Shift key when you see the login window (NOTE: If you 
have FileVault enabled you may need to log in twice). 
Test to see what happens
Exit Safe Mode by restarting your Mac as normal 
Test again to see what happens


Note, booting into Safe Mode will take longer than usual.

Run Apple Diagnostics

Okay, time to test your hardware. Follow these steps to run Apple Diagnostics:


Fully shut down your Mac
Restart your Mac
Immediately press the D key and keep it down until you see the Diagnostics screen appear
Wait for Diagnostics to finish (this typically only takes a few minutes)
Once complete, one of two things will appear on the screen:


a No issues found message
a brief description of any errors found plus further instructions

If the diagnostics test does find errors, take a note of what they are


Note: If pressing and holding the D key at Step 3 doesn't work, start again at Step 1 and, at Step 3 press and hold both the OptionD keys instead. This will try and run diagnostics from the internet instead, so you will need to allow more time for it to complete. 

Regardless, let me know how you went.