-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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 does ImageDataGenerator work with Merged model? #3466
Comments
ShunyuanZ
changed the title
How does ImageGenerator work with Merged model?
How does ImageDataGenerator work with Merged model?
Aug 13, 2016
how about conbime genrator? |
you can define youself Iterator like this:
and use:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So the problem is that, my validation set is too large and can't fit in memory. Then Following issue #2702, I tried to do batch on validation set with ImageDataGenerator and datagen.flow(X,y). However here comes the tricky part:
My model is a merged model, combining two sequential models. With left branch dealing with 3 channel RGB images and right branch a vector representing some text information. So the input in my CNN is {image, text}, and the output is {label}. I guess ImageDataGenerator only deals with images, so it will be problematic if multiple sources (and different types) of X (inputs) are passed. The following is what I did:
# merge two branches
from keras.layers import Merge
left_branch=model_image
right_branch=model_text
model=Sequential()
model.add(Merge([left_branch, right_branch], mode='concat'))
model.compile(loss='mean_squared_error', optimizer='adadelta',metrics=['accuracy'])
# define data generators
from keras.preprocessing.image import ImageDataGenerator
datagen_train= ImageDataGenerator(rescale=1./255, shear_range=0.2, zoom_range=0.2)
datagen_validation= ImageDataGenerator(rescale=1./255)
# model fit use fit_generator
Then I got the following error:
Where 40000 is the training-set size, (3,224,224) represent my RGB 224x224 images.
If I just ignored validation set, and do the following (disable validation in model.fit), then it worked:
This way, the images and texts are successfully passed through the two branches, however, I wound't be able to record and monitor validation loss in the training process....
Could someone give a suggestion? I'd like to know how to batch on validate set, or a way of making ImageDataGenerator working with Merged model. Thank you!!!
The text was updated successfully, but these errors were encountered: