I checked all similar messages, but my error was not fixed with the proposed fixes. Thanks in advance for your help!
I use an endorflow server with Keras, and my images are 1185 by 676 in size. Most of the code refers to one Keras example.
I get 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 I use shadoworflow and not anano.
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, data generation is part of the problem:
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)