SHARE
TWEET

Untitled

a guest Sep 16th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from keras.datasets import mnist
  2. from keras.models import Sequential
  3. from keras.layers.core import Dense, Activation
  4. from keras.utils import np_utils
  5.  
  6. (X_train, Y_train), (X_test, Y_test), = mnist.load_data()
  7.  
  8. X_train = X_train.reshape(60000, 784)
  9. X_test = X_test.reshape(10000, 784)
  10.  
  11. classes = 10
  12. Y_train = np_utils.to_categorical(Y_train, classes)
  13. Y_test = np_utils.to_categorical(Y_test, classes)
  14. input_size = 784
  15. batch_size = 100
  16. hidden_neurons = 100
  17. epochs = 15
  18.  
  19.  
  20.  
  21. model = Sequential()
  22. model.add(Dense(hidden_neurons, input_dim=input_size))
  23. model.add(Activation('sigmoid'))
  24. model.add(Dense(classes, input_dim=hidden_neurons))
  25. model.add(Activation('softmax'))
  26. model.compile(loss='categorical_crossentropy', metrics=['accuracy'], optimizer='sgd')
  27. model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=epochs, verbose=1)
  28. score = model.evaluate(X_test, Y_test, verbose=1)
  29. print('Dokladnosc testu:', score)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top