Accurate channel state information is paramount for fully harnessing the benefits of massive antennas in communication systems. However, two primary challenges impede its acquisition. Firstly, conventional far-field assumption-based channel estimation schemes become impractical in near-field dominant future communication systems. In contrast to the far-field assumption, which relies solely on angle-dependent channels, the near-field introduces location-dependency. The second challenge involves limited research on hybrid beamformer design during the channel estimation period, unlike the extensive focus on the data transmission period. To overcome these hurdles, this paper presents a neural network-aided joint optimization of the beamformer and localization function for near-field channel estimation, customized to the specific environment. Inspired by the similarity between operations in a neural network and a signal model, the initial network weights emulate the beamforming matrix during training. Subsequently, these weights are extracted for beamformer design, while the remainder of the network serves as the localization function. Following localization, the location parameters undergo refinement, paving the way for precise channel reconstruction. Unlike prevailing near-field channel estimation methods that solely exploit range information from array response, our approach additionally leverages range-dependent frequency selectivity characteristics. Simulation results prove the adaptability of the proposed beamformer to given environments and demonstrate the superior performance of the proposed method in channel estimation.