Quantcast
Channel: Incompatible shapes: [128,1] vs. [128,3,3] - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Incompatible shapes: [128,1] vs. [128,3,3]

$
0
0

I am trying to create a CNN to classify the SVHN dataset but run into an incompatible shape error when creating my model: Incompatible shapes: [128,3,3,10] vs. [128,1]. How do I fix it?

         model = Sequential([                          Conv2D(filters=8, kernel_size=(3, 3),                            activation='relu', input_shape=(32, 32,3                            name='conv_1'),                           Conv2D(filters=8, kernel_size=(3, 3),                           activation='relu', padding= 'SAME',                                     `name='conv_2'),                           MaxPooling2D(pool_size=(8, 8), name='pool_1'),                            Dense(64,  kernel_regularizer =                             regularizers.l2(0.5),bias_initializer='ones',                            activation='relu' , name='dense_1'),                            Dropout(0.3),                              Dense(64,kernel_regularizer =                             regularizers.l2(0.5) , activation='relu'                           ,name='dense_2'),                            BatchNormalization(),                              Dense(64,  kernel_regularizer =                             regularizers.l2(0.5) ,  activation='relu'                             ,name='dense_3'),                             Dense(10,  activation='softmax'                             ,name='dense_4')             ])           model.compile(           optimizer = 'adam',           loss = 'sparse_categorical_crossentropy',           metrics= ['accuracy' ])           history = model.fit(train_images,train_labels , epochs = 30            ,validation_split = 0.15,                batch_size= 128, verbose = False )

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>