-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to batch train with fit_generator()? #7729
Comments
I don't think you should use From your code I understand you want to go through your whole dataset on one epoch of your
I opted for the latter, and it works well, though be careful of the threading nature of the method (it may try to fetch data outside your range, hence my condition in the example below:)
Don't mind my |
@StripedBanana Thanks. I'll address the for loop. However i'm still at a loss. Am I correct in assuming that the generator has to return the data in batches in order for fit_generator() to batch train? |
Yes, the generator has to return the data in batches. But the problem is that you put |
@myutwo150 Thanks. I have now corrected that.
So I'm not sure it's a problem. |
Would also be interested in that! Other than that, I'd rather use DataFlow from tensorpack if you're concerned about the speed of the generator. Anyways, here's another snippet of a generator (with hdf5 files as input though and not csv) if it helps:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
Apologies if this is the wrong place to raise my issue (please help me out with where best to raise it if that's the case). I'm a novice with Keras and Python so hope responses have that in mind.
I'm trying to train a CNN steering model that takes images as input. It's a fairly large dataset, so I created a data generator to work with fit_generator(). It's not clear to me how to make this method trains on batches, so I assumed that the generator has to return batches to fit_generator(). The generator looks like this:
It reads a csv file containing telemetry data (steering angle etc) and paths to image samples, and returns arrays of size: batchsz
The call to fit_generator() looks like this:
The dataset contains 113526 sample points yet the model training update output reads like this (for example):
Which appears to be training sample by sample (stochastically?).
The resultant model is useless. I previously trained on a much smaller dataset using .fit() with the whole dataset loaded into memory, and that produced a model that at least works even if poorly. Clearly something is wrong with my fit_generator() approach. Will be very grateful for some help with this.
The text was updated successfully, but these errors were encountered: