'Deep learning CNN: low accuracy

I am training a convolutional neural network for binary time series classification. The training accuracy on both models is very different. If on the first it grows, then on the second it is always about 40%. There were also strong "jumps". Change filters=32/64/128 and epochs didn't give the best results(kernel_size = 8).

self.model = keras.Sequential([            
            Conv1D(64, kernel_size=self.kernel_size, activation='relu', input_shape=(self.frame_length, self.N_Feature)),
            BatchNormalization(),
            MaxPooling1D(),    
            
            Conv1D(128, kernel_size=self.kernel_size, activation='relu'),
            BatchNormalization(),
            MaxPooling1D(),    
            
            Conv1D(256, kernel_size=self.kernel_size, activation='relu'),
            BatchNormalization(),
            MaxPooling1D(),    
            
            Dropout(self.dropout_rate),
            Flatten(),
            Dense(self.N_classes, activation='sigmoid')
        ])        
        self.model.compile(optimizer='sgd',loss='binary_crossentropy',metrics='Accuracy')

some learning outcomes



Solution 1:[1]

I am taking a very wild guess (since your question is missing a lot of information), that your "self.N_classes" variable is "2"?

BinaryCrossentropy (your loss) needs it to be "1" though. So instead of labels being "[0, 1]" and "[1, 0]" they should be "0" and "1". If you change your labels, your loss should be calculated meaningfully and your training should work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PlzBePython