what is the use of line pool3_flat=tf.reshape(pool3,shape=[-1,pool3_fmaps77])
You are reshaping the pooling layer(pool3) to the shape of 77pool3_fmaps
https://www.tensorflow.org/api_docs/python/tf/reshape