There are a couple of potential traps with the scenario you seem to be outlining. Many of them have already been addressed in literature on inertial navigation. You can find many good references on inertial navigation and dead reckoning using IMUs, and you may want to look into that, depending on your goals.
What you are asking for is a method to clean up your raw IMU data using an EKF. This is a bit of a strange request, because the EKF is generally designed for dynamic systems. In our context, it's sufficient to say that dynamic systems are driven by some known process in between measurements; for instance, if you were estimating position and velocity, there is a known relationship (derivative) that describes how the velocity affects position in between measurements from, e.g., a GPS receiver. You have not mentioned any other measurements, like GPS, that you want to use in the filter. If you don't have any other measurements available, then an EKF is not going to buy you anything in practice, and is probably much more challenging to set up.
If all you want is filtered accelerometer, gyroscope, and magnetometer data, then I would suggest designing a low-pass filter to smooth those data instead. You would also want to make sure to calibrate the bias of the accelerometer and gyros by reading the first N measurements, and then subtracting the average of those values from all subsequent measurements. Depending on your application and the motion of your vehicle, you might have usable data for as many as several minutes. I'm making some fairly wild guesses about your IMU bias drift rates, since I'm not familiar with the MPU-9250. In general, I would not trust a MEMS IMU output for too long, since there will always be bias drift. There are ways to address this limitation: you could augment the IMU with additional sensors, or you could re-calibrate periodically by stopping the vehicle and taking measurements. Unfortunately, the latter approach is only really very realistic if you have a ground vehicle moving over fairly level terrain.
It's not clear if your application is for a flying vehicle or for an underwater one, nor is it clear what your desired inputs and outputs for an ANN-based controller are. For instance, if all you are giving the controller is IMU data, what will be its objectives? It sounds like what you may want to do is perform inertial navigation. Assuming you have an underwater vehicle, you will mostly likely want to perform dead reckoning. Essentially, dead reckoning integrates the accelerometer histories twice to estimate the position of the vehicle, and the gyro histories once to estimate its orientation. If you have estimates of the position, then you could give your controller simple commands, such as "go to position X = 5 m" and then have the controller try to do that. (You can do the same thing with accelerations, of course, but I'm not sure what the point would be, since the vehicle won't be capable of even basic autonomy.)
filtfilt
), but then you're left training a neural network with unrealistic (unobtainable) data. Did you want to use the NN to get from raw IMU output to a pose estimate or are you trying to use the NN to get from a reference error to a control signal? $\endgroup$