Advertisement
anhlocpr

Untitled

May 12th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. from keras.models import Sequential
  2. from keras.layers import Dense
  3. import numpy
  4.  
  5. dataset = numpy.loadtxt("../file_trainning", delimiter=",")
  6. X = dataset[:, 1:785]
  7. Y = dataset[:, 0]
  8.  
  9.  
  10. model = Sequential()
  11. model.add(Dense(12, input_dim=784, activation='relu'))
  12. model.add(Dense(8, activation='relu'))
  13. model.add(Dense(1, activation='sigmoid'))
  14.  
  15. model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  16. model.fit(X, Y, epochs=1, batch_size=10)
  17. scores = model.evaluate(X,Y)
  18. print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))
  19. predictions = model.predict(X)
  20. rounded = [round(x[0]) for x in predictions]
  21. print(rounded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement