Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. from keras.models import Sequential
  2. from keras.layers import Dense
  3. from keras.layers.core import Activation, Dense
  4.  
  5. # define base mode
  6. def baseline_model():
  7. # create model
  8. model = Sequential()
  9. model.add(Dense(1, input_dim=1, init='normal', activation='relu'))
  10. model.add(Dense(1, init='normal'))
  11. model.compile(loss='mean_squared_error', optimizer='adam')
  12. return model
  13.  
  14. regr = baseline_model()
  15. regr.fit(X_train, Y_train,
  16. nb_epoch=200, validation_split=0.2, verbose = 1) #batch_size=5,
  17.  
  18. Epoch 197/200
  19. 64/64 [==============================] - 0s - loss: 34810.5195 - val_loss: 131652.9375
  20. Epoch 198/200
  21. 64/64 [==============================] - 0s - loss: 34809.8574 - val_loss: 131651.5000
  22. Epoch 199/200
  23. 64/64 [==============================] - 0s - loss: 34809.2266 - val_loss: 131650.0781
  24. Epoch 200/200
  25. 64/64 [==============================] - 0s - loss: 34808.5801 - val_loss: 131648.6406
  26.  
  27. plt.scatter(X_test, Y_test, color='black')
  28. plt.plot(X_test, regr.predict(X_test), color='blue',
  29. linewidth=3)
  30.  
  31. plt.xticks()
  32. plt.yticks()
  33.  
  34. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement