Forecasting energy consumption and demand is a crucial and difcult problem for real-time implementation. For the customer and power providers to monitor, schedule, and operate the electrical equipment safely, there must be proper cooperation. In this research, we provide a brand-new neural network-based procedure of optimization for forecasting energy consumption. For obtaining the necessary power demand forecast at the user end, the deep belief networks (DBN) technique is frst used. The structure of the DBN was then improved based on the developed gorilla troops optimizer (DGTO). The suggested DBN/ DGTO method is then applied to a standard case study with three types of demands, short, long, and medium-term, and a comparison is implemented between its results and some other published techniques. The results demonstrate that using the proposed technique can be considered a useful technique for energy consumption forecasting purposes.