Higher requirements must be put forward about wireless signal transmission in harsh environments. Energy loss mitigation, channel estimation, noise interference reduction demands high quality of service in wireless communication. In the fifth generation wireless communication, massive multiple-input multiple-output (MIMO) networks have been used and play a significant role to fulfill the requirements. Cell-Free massive MIMO networks are recognized as possible solution in the future wireless communication. Spectral efficiency (SE) is a very important index in assessing massive MIMO networks. This article tries to optimize both SE and power control of cell-free massive MIMO networks. Both uplink and downlink transmission are included in the study. The optimization model contains both SE and power control of massive MIMO networks. To tackle the model, a novel ensemble method is developed inspired by ensemble learning. The ensemble method is built up on the neighborhood field optimization method. The goodness of the developed ensemble method is verified by comparing with genetic algorithm, gradient descent method and Newton method. Extensive simulations are performed to study the optimization of SE and power control. Different wireless sensors are taken into consideration to simulate different requirements of massive MIMO networks. The results demonstrate the effectiveness of the proposed method for applying in massive MIMO networks.INDEX TERMS Massive multiple-input multiple-output, neighborhood field optimization, optimization, power control, spectral efficiency.