#StackBounty: #neural-networks #conv-neural-network Convolutional neural network fails even when given answer

Bounty: 50

I was having problems with a CNN giving the prediction as true for everything regardless of input. Taking advice from this forum, I simplified the input to give it the output as the input and it’s still unable to make the prediction correctly! Shape is 99,22, 2. The output boolean is in the input in the 3rd dimension of the input.

Here’s an example of 1 sample of the input: https://pastebin.com/jCVU3brn to predict the output as 0.

def CNN(train_X, train_y, test_X, test_y):

model = Sequential([
  Conv2D(30, kernel_size=3, activation="relu", input_shape=(99, 25, 2)),
  Conv2D(64, kernel_size=3, activation="relu"),
  Flatten(),
  Dense(1, activation='softmax')
])

    # Compile the model.
model.compile(
  'adam',
  loss='categorical_crossentropy',
  metrics=['accuracy'],
)

# Train the model.
model.fit(
  train_X,
  train_y,
  epochs=1
)
preds = np.round(model.predict(test_X), 0)    

return preds

Model summary:

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_11 (Conv2D)           (None, 97, 23, 30)        570       
_________________________________________________________________
conv2d_12 (Conv2D)           (None, 95, 21, 64)        17344     
_________________________________________________________________
flatten_4 (Flatten)          (None, 127680)            0         
_________________________________________________________________
dense_4 (Dense)              (None, 1)                 127681    
=================================================================
Total params: 145,595
Trainable params: 145,595
Non-trainable params: 0


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.