Well, as you see, it’s a bit hard to make the computation by hand 
The quickest way to have working code is just swapping the 512 * 7 * 7 out by 2048… However, that does not really tell you if your network is doing what you want it to.
I recommend printing the shape of every layer’s input and ouput to verify your calculations, which look fine after a very quick look. Then you’ll know what happens and probably why as well!