Guest User

Untitled

a guest
Jul 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. model = Sequential()
  2. model.add(LSTM(
  3. 256,
  4. input_shape=(network_input.shape[1], network_input.shape[2]),
  5. return_sequences=True
  6. ))
  7. model.add(Dropout(0.3))
  8. model.add(LSTM(512, return_sequences=True))
  9. model.add(Dropout(0.3))
  10. model.add(LSTM(512))
  11. model.add(Dense(256))
  12. model.add(Dropout(0.3))
  13. model.add(Dense(n_vocab))
  14. model.add(Activation('softmax'))
  15. model.summary()
  16. model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
  17.  
  18. filepath = "weights-improvement-{epoch:02d}-{loss:.4f}-bigger.hdf5"
  19. checkpoint = ModelCheckpoint(
  20. filepath,
  21. monitor='loss',
  22. verbose=0,
  23. save_best_only=True,
  24. mode='min'
  25. )
  26. callbacks_list = [checkpoint]
  27.  
  28. history = model.fit(network_input, network_output, validation_split=0.33,
  29. epochs=600, batch_size=64, callbacks=callbacks_list)
  30. print(history.history.keys())
  31.  
  32. # acc history
  33. plt.plot(history.history['acc'])
  34. plt.plot(history.history['val_acc'])
  35. plt.title('model accuracy')
  36. plt.ylabel('accuracy')
  37. plt.xlabel('epoch')
  38. plt.legend(['train', 'test'], loc='upper left')
  39. plt.savefig("acc_history.png")
  40. plt.close()
  41.  
  42. plt.plot(history.history['loss'])
  43. plt.plot(history.history['val_loss'])
  44. plt.title('model loss')
  45. plt.ylabel('loss')
  46. plt.xlabel('epoch')
  47. plt.legend(['train', 'test'], loc='upper left')
  48. plt.savefig("history_loss.png")
Add Comment
Please, Sign In to add comment