Generalization Bounds for Gradient Methods via Discrete and Continuous Prior