I've checked all the similar posts, but my error isn't being fixed with the fixes suggested. Thanks in advance for any help!
I'm using a tensorflow backend with Keras, and my images have dimensions 1185 by 676. Most of the code is from one of the Keras examples.
I'm getting ValueError: Negative dimension size caused by subtracting 2 from 1 for 'MaxPool' (op: 'MaxPool') with input shapes: [?,1,1183,32].
This error disappears when I switch to dim_ordering="th", which is odd, considering that I'm using tensorflow, not theano.
The code up to this point:
img_width, img_height = 1185, 676
train_data_dir = 'data/train'
validation_data_dir = 'data/validation'
nb_train_samples = 32
nb_validation_samples = 8
nb_epoch = 3
model = Sequential()
model.add(Convolution2D(32, 3, 3, input_shape=(3, img_width, img_height)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2), dim_ordering="tf"))
And just in case the data generation is part of the issue:
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
train_datagen = ImageDataGenerator(
rescale=1./255,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True)
test_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
train_data_dir,
batch_size=4,
target_size=(img_width, img_height),
class_mode='binary')
validation_generator = test_datagen.flow_from_directory(
validation_data_dir,
batch_size=4,
target_size=(img_width, img_height),
class_mode='binary')
model.fit_generator(
train_generator,
samples_per_epoch=nb_train_samples,
nb_epoch=nb_epoch,
validation_data=validation_generator,
nb_val_samples=nb_validation_samples)