SHARE
TWEET

Untitled

a guest Jun 20th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2.  
  3. def sigmoid(x):
  4.     return 1/(1+np.exp(-x))
  5.  
  6. traning_inputs= np.array([[0,0,1],
  7.                           [1,1,1],
  8.                           [1,0,1],
  9.                           []])
  10.  
  11. traning_outputs = np.array([[0,1,1,0]]).T
  12.  
  13. np.random.seed(1)
  14.  
  15. synaptic_weights = 2 * np.random.random((3,1))-1
  16.  
  17. print("Случайные что-то там:")
  18. print(synaptic_weights)
  19. for i in range(20000):
  20.     input_layer=traning_inputs
  21.     outputs = sigmoid(np.dot(input_layer,synaptic_weights))
  22.     err = training_outputs-outputs
  23.     adjustents = np.dot(input_layer.T,err * (outputs * (1-outputs)))
  24.  
  25.     synaptic_weights+= adjustents
  26. print("Ещё 123")
  27. print(synaptic_weights)
  28.  
  29.  
  30. input_layer = traning_inputs
  31. outputs = sigmoid( np.dot(imput_layer, synaptic_weights))
  32.  
  33. print("Результат:")
  34. print(outputs)
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
 
Top