If it works and it’s in line with the formulas given, it should be alright.
I would recommend putting the calculations into their own methods, though. There’s a lot of copy&paste going one which makes to annoying to make changes, e.g., adding more layers.
Maybe you can have a look at some older code of mine, particularly at the methods _calc_conv_output_size() and _calc_maxpool_output_size() and how/where they are used. I think this makes more flexible and cleaner coding.