title: Validation accuracy much lower than training accuracy in Keras for text classification
body: <p>I am new to Keras and trying to create a model. The issue is that my training accuracy is around 80 percent but the validation accuracy is drastically low at 15 percent. I have 545 rows in my dataset. I have normalized all the input features. Any help on what can be tweaked would be really helpful.</p>
  
  <p>Sharing the complete data and code here</p>
  
  <p><a href="https://drive.google.com/open?id=1g8Cmw2bmAI9DnOU-rB4sjsOeBuFp6NUy" rel="nofollow noreferrer">https://drive.google.com/open?id=1g8Cmw2bmAI9DnOU-rB4sjsOeBuFp6NUy</a></p>
  
  <pre><code>   #Normalize data
  
  data[,1:(ncol(data)-1)] = normalize(data[,1:(ncol(data)-1)])
  
  data[,ncol(data)] = as.numeric(data[,ncol(data)]) - 1
  
  set.seed(128)
  
  ind = sample(2,nrow(data),replace = T,prob = c(0.7,0.3))
  
  training = data[ind==1,1:(ncol(data)-1)]
  
  test = data[ind==2,1:(ncol(data)-1)]
  
  traintarget = data[ind==1,ncol(data)]
  
  testtarget = data[ind==2,ncol(data)]
  # One hot encoding
  trainLabels = to_categorical(traintarget)
  testLabels = to_categorical(testtarget)
  print(testLabels)
  
  model = keras_model_sequential()
  
  model %&gt;% 
    layer_dense(units = 150, activation = 'relu', input_shape = c(520)) %&gt;% 
    layer_dense(units = 50, activation = 'relu') %&gt;%
    layer_dense(units = 9, activation = 'softmax') 
  
  
  model %&gt;%
    compile(loss = 'categorical_crossentropy', optimizer = 'adam',metrics = 'accuracy')
  
  
  history = model %&gt;%
    fit(training,
        trainLabels,
        epoch = 300,
        batch_size = 32,
        validation_split = 0.2)
  
  prob = model %&gt;%
    predict_proba(test)
  
  pred = model %&gt;%
    predict_classes(test)
  
  table2 = table(Predicted = pred, Actual = testtarget)
  
  cbind(prob,pred,testtarget)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/bVrUQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bVrUQ.jpg" alt="Graph"></a></p>