Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent overfitting #19

Open
lukaszog opened this issue Aug 20, 2018 · 0 comments
Open

Prevent overfitting #19

lukaszog opened this issue Aug 20, 2018 · 0 comments

Comments

@lukaszog
Copy link

Hi,
I train your model on one midi file and I split data into test and valid. Next I plot test/valid and I see that model is overfit. Did you known how to prevent this?

# build a 2 stacked LSTM
  model = Sequential()
  model.add(LSTM(128, return_sequences=True, input_shape=(max_len, N_values)))
  model.add(Dropout(0.2))
  model.add(LSTM(128, return_sequences=False))
  model.add(Dropout(0.2))
  model.add(Dense(N_values))
  model.add(Activation('softmax'))

  model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])

  history = model.fit(X, y, batch_size=128, nb_epoch=N_epochs, validation_split=0.22)

  print(history.history.keys())

  # acc history
  plt.plot(history.history['acc'])
  plt.plot(history.history['val_acc'])
  plt.title('model accuracy')
  plt.ylabel('accuracy')
  plt.xlabel('epoch')
  plt.legend(['train', 'test'], loc='upper left')
  plt.savefig("acc_history.png")
  plt.close()

  plt.plot(history.history['loss'])
  plt.plot(history.history['val_loss'])
  plt.title('model loss')
  plt.ylabel('loss')
  plt.xlabel('epoch')
  plt.legend(['train', 'test'], loc='upper left')
  plt.savefig("history_loss.png")


  return history

acc_history
history_loss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant