The paradigm shift from ''connected things'' to ''connected intelligence'' is anticipated to be made possible by the sixth-generation wireless systems, which typically use millimeter wave beamforming to mitigate the significant propagation loss. However, beamforming design in millimeter wave communications poses many different challenges owing to the large antenna arrays with the limitation of radio frequency chains and analog beamforming architectures. To circumvent this problem, deep learning models have recently been utilized as a disruptive method for solving difficult optimization problems in sixth-generation mobile systems, such as maximizing spectral efficiency. However, it is still unclear how to produce high-performance deep learning models which require considering appropriate hyperparameters. This study proposes a metaheuristics-based approach for optimizing hyperparameters that are used to build optimized deep learning models to maximize spectral efficiency. The research results demonstrate that the proposed approach-based models establish higher spectral efficiency than the state-of-the-art approach-based models and the reference model whose hyperparameters are based on empirical trials.