Wemos d1 r2 losing sketch after power cycle

When I programmed my wemos I did not change any modes - I'm guessing the IDE took care of that .
Have a look at the 8266 programming , on that you have to set the pins correctly - might help you, the Wemos page or its forum might help too