In this paper a neural network heuristic dynamic programing (HDP) is used for optimal control of the virtual inertia-based control of grid connected three-phase inverters. It is shown that the conventional virtual inertia controllers are not suited for non-inductive grids. A neural network-based controller is proposed to adapt to any impedance angle. Applying an adaptive dynamic programming controller instead of a supervised controlled method enables the system to adjust itself to different conditions. The proposed HDP consists of two subnetworks: critic network and action network. These networks can be trained during the same training cycle to decrease the training time. The simulation results confirm that the proposed neural network HDP controller performs better than the traditional direct-fed voltage an/or reactive power controllers in virtual inertia control schemes.Index Terms--grid connected inverter, heuristic dynamic programming, neural network, virtual synchronous generator I. X , L X , and L R are the inverter output filter reactance, the inverter to the grid line reactance, and the inverter to grid line resistance respectively.