Body: <p>I am trying to solve a multiclass classification problem using Keras. The current network looks as follows:</p>
  <pre><code>model = tf.keras.models.Sequential()
  model.add(tf.keras.layers.LSTM(128, time_major=False,return_sequences=False, return_state=False))
  model.add(Dense(64, activation='relu'))
  model.add(Dense(32, activation='relu'))
  model.add(Dense(4, activation='softmax'))
  
  model.compile(tf.keras.optimizers.RMSprop(),
                loss='categorical_crossentropy', 
                metrics=['accuracy'])
  </code></pre>
  <p>The accuracy value doesn't go beyond 0.3.</p>
  <p>I have tried to change the value of the learning rate, use a more complex or simplest network, change the activation function of the last layer to sigmoid...</p>
  <p>The results I obtained are:</p>
  <pre><code>Epoch 2/1000
  80/80 [==============================] - 2s 30ms/step - loss: 1.3860 - accuracy: 0.3675 - val_loss: 1.3859 - val_accuracy: 0.3641
  Epoch 3/1000
  80/80 [==============================] - 3s 32ms/step - loss: 1.3858 - accuracy: 0.3675 - val_loss: 1.3857 - val_accuracy: 0.3641
  Epoch 4/1000
  80/80 [==============================] - 2s 30ms/step - loss: 1.3856 - accuracy: 0.3675 - val_loss: 1.3855 - val_accuracy: 0.3641
  Epoch 5/1000
  80/80 [==============================] - 2s 31ms/step - loss: 1.3854 - accuracy: 0.3675 - val_loss: 1.3853 - val_accuracy: 0.3641
  Epoch 6/1000
  80/80 [==============================] - 2s 30ms/step - loss: 1.3852 - accuracy: 0.3675 - val_loss: 1.3851 - val_accuracy: 0.3641
  </code></pre>
  <p>I have used 80% of the data for training and 20% for validation and have a total of 20.000 cases.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-12T11:51:07.997Z
Comments.Text: You are asking the wrong question, the problem is that the loss is not decreasing, maybe the model is not complex enough or use a different optimizer.
Comments.UserDisplayName: Dr. Snoopy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-12T13:13:38.907Z
Comments.Text: You need to provide more details about your data. Does 80/80 mean you have only 80 samples? It looks like you're expecting the model to perform well after 6 iterations
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-13T17:45:52.183Z
Comments.Text: I have a data set of 20.000 cases. And I only posted the results of the first 6 epochs to keep it simple here, but I obtain the same result after 2000 epochs. I have already tried with different optimizers such as RMSprop, Adam, SGD, etc. I'll keep trying.
Comments.UserDisplayName: isostar
Tags: <tensorflow><keras><multiclass-classification>
Title: Why does the accuracy get stuck at a constant value when using Keras for multiclass singles-label classification problem?
UserDisplayName: isostar
ThreadText: # Why does the accuracy get stuck at a constant value when using Keras for multiclass singles-label classification problem?
  
  (Asked by: username_0 on 2024-01-12)
  
  I am trying to solve a multiclass classification problem using Keras. The current network looks as follows:
  
  ```
  model = tf.keras.models.Sequential()
  model.add(tf.keras.layers.LSTM(128, time_major=False,return_sequences=False, return_state=False))
  model.add(Dense(64, activation='relu'))
  model.add(Dense(32, activation='relu'))
  model.add(Dense(4, activation='softmax'))
  
  model.compile(tf.keras.optimizers.RMSprop(),
                loss='categorical_crossentropy', 
                metrics=['accuracy'])
  
  ```
  
  The accuracy value doesn't go beyond 0.3.
  
  I have tried to change the value of the learning rate, use a more complex or simplest network, change the activation function of the last layer to sigmoid...
  
  The results I obtained are:
  
  ```
  Epoch 2/1000
  80/80 [==============================] - 2s 30ms/step - loss: 1.3860 - accuracy: 0.3675 - val_loss: 1.3859 - val_accuracy: 0.3641
  Epoch 3/1000
  80/80 [==============================] - 3s 32ms/step - loss: 1.3858 - accuracy: 0.3675 - val_loss: 1.3857 - val_accuracy: 0.3641
  Epoch 4/1000
  80/80 [==============================] - 2s 30ms/step - loss: 1.3856 - accuracy: 0.3675 - val_loss: 1.3855 - val_accuracy: 0.3641
  Epoch 5/1000
  80/80 [==============================] - 2s 31ms/step - loss: 1.3854 - accuracy: 0.3675 - val_loss: 1.3853 - val_accuracy: 0.3641
  Epoch 6/1000
  80/80 [==============================] - 2s 30ms/step - loss: 1.3852 - accuracy: 0.3675 - val_loss: 1.3851 - val_accuracy: 0.3641
  
  ```
  
  I have used 80% of the data for training and 20% for validation and have a total of 20.000 cases.
  
  **Tags:** tensorflow, keras, multiclass-classification
  
  > **Comments:**
  > **username_1**: You are asking the wrong question, the problem is that the loss is not decreasing, maybe the model is not complex enough or use a different optimizer.  
  > **username_2**: You need to provide more details about your data. Does 80/80 mean you have only 80 samples? It looks like you're expecting the model to perform well after 6 iterations  
  > **username_0**: I have a data set of 20.000 cases. And I only posted the results of the first 6 epochs to keep it simple here, but I obtain the same result after 2000 epochs. I have already tried with different optimizers such as RMSprop, Adam, SGD, etc. I'll keep trying.  
  
  ---
  
  ## 0 answers
  
  