Guest User

Untitled

a guest
Aug 14th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. from __future__ import print_function
  2. import keras
  3. from keras.models import Sequential
  4. from keras.layers import Dense
  5. from keras.utils import to_categorical
  6. import numpy as np
  7.  
  8. np.random.seed(0)
  9.  
  10. X = np.array([[0.1, 0.5], [1.1, 2.3], [-1.1, -2.3], [-1.5, -2.5]])
  11. y = np.array([0, 1, 2, 2])
  12.  
  13. y_enc = to_categorical(y)
  14.  
  15. W = np.array([[0.1, 0.2, 0.3],
  16. [0.1, 0.2, 0.3]])
  17.  
  18. b = np.array([0.01, 0.1, 0.1])
  19.  
  20. model = Sequential()
  21. model.add(Dense(3, weights=[W,b] , input_dim=2))
  22. model.summary()
  23. model.compile(loss='categorical_crossentropy', optimizer='Adam')
  24. print(model.evaluate(X , y_enc))
Add Comment
Please, Sign In to add comment