Categories
Misc

ValueError: Negative dimension size caused by subtracting 2 from 1

def get_model_2(input_shape): model = Sequential() model.add(Conv2D(64, (5, 5), activation='relu', input_shape=input_shape)) model.add(MaxPooling2D(pool_size=(3, 3))) model.add(Conv2D(128, (4, 4), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Conv2D(512, (3, 3), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Conv2D(512, (3, 3), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) # model.add(Conv2D(512, (3, 3), activation='relu')) # model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Conv2D(512, (2, 2), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Flatten()) model.add(Dense(512, activation='relu')) # model.add(Dropout(0.5)) model.add(Dense(1, activation='sigmoid')) return model 

Why do I get the following error when I un-comment that middle
layer?

ValueError: Negative dimension size caused by subtracting 2 from
1 for ‘{{node max_pooling2d_4/MaxPool}} = MaxPool[T=DT_FLOAT,
data_format=”NHWC”, explicit_paddings=[], ksize=[1, 2, 2, 1],
padding=”VALID”, strides=[1, 2, 2, 1]](Placeholder)’ with input
shapes: [?,1,1,512].

submitted by /u/BananaCharmer

[visit reddit]

[comments]

Leave a Reply

Your email address will not be published.