Context. Validating the accelerating expansion of the universe is an important aspect in improving our understanding of the evolution of the universe. By constraining the cosmic acceleration parameter XH, we can discriminate between the cosmological constant plus cold dark matter (ΛCDM) model and the Lemaître–Tolman–Bondi (LTB) model. Aims. In this paper, we explore the possibility of constraining the cosmic acceleration parameter with the inspiral gravitational waveform of neutron star binaries (NSBs) in the frequency range of 0.1 Hz–10 Hz, which can be detected by the second-generation space-based gravitational wave detector DECIGO. Methods. We used a convolutional neural network (CNN) and a long short-term memory (LSTM) network combined with a gated recurrent unit (GRU), along with a Fisher information matrix to derive constraints on the cosmic acceleration parameter, XH. Results. We assumed that our networks estimate the cosmic acceleration parameter without biases (the expected value of the estimation is equal to the true value). Under this assumption, based on the simulated gravitational wave data with a time duration of one month, we conclude that CNN can limit the relative error to 15.71%, while LSTM network combined with GRU can limit the relative error to 14.14%. Additionally, using a Fisher information matrix for gravitational wave data with a five-year observation can limit the relative error to 32.94%. Conclusions. Under the assumption of an unbiased estimation, the neural networks can offer a high-precision estimation of the cosmic acceleration parameter at different redshifts. Therefore, DECIGO is expected to provide direct measurements of the acceleration of the universe by observing the chirp signals of coalescing binary neutron stars.