• API
• FAQ
• Tools
• Archive
A Pastebin account makes a great Christmas gift
SHARE
TWEET

# Untitled

a guest Nov 14th, 2017 60 Never
ENDING IN00days00hours00mins00secs

1. import math
2.
3. def sig(x):
4.   return 1 / (1 + math.exp(-x))
5.
6. b = [0,1]
7.
8. # INPUT WEIGHTS #
9.
10. w1 = [ 2, 1,-3,-4,-4, 4]
11. w2 = [-2,-3, 1, 4, 5,-4]
12. w3 = [ 3, 1,-3,-4,-3, 5]
13. w4 = [-4,-2,-2,-4,-4,-3]
14.
15. W = [w1,w2,w3,w4]
16.
17. def nn(X1,X2,w):
18.   H1 = sig(w[0]*X1+w[2]*X2+0.5)
19.   H2 = sig(w[1]*X1+w[3]*X2+0.5)
20.   Y  = sig(w[4]*H1+w[5]*H2+0.5)
21.   return round(Y)
22.
23. print('┌──┐  w0  ┌──┐')
24. print('│X1├─────>│H1│')
25. print('└──┘      └──┘')
26. print('    \     ^   \\ w4')
27. print('  w1 \   /     \\')
28. print('      \ /       >┌───┐')
29. print('       X         │ Y │')
30. print('      / \       >└───┘')
31. print('  w2 /   \     / ')
32. print('    /     v   / w5')
33. print('┌──┐  w3  ┌──┐')
34. print('│X2├─────>│H2│')
35. print('└──┘      └──┘')
36.
37. print('Weights = ',W)
38.
39. print("┌────┬────┬────┬────┬────┬────┬────┐")
40. print("│X1  │X2  │AND │OR  │NAND│NOR │ NN │")
41.
42. for v in W:
43.   print("├────┼────┼────┼────┼────┼────┼────┤")
44.   for i in b:
45.     for j in b:
46.       print("│ "+str(i),j,i and j,i or j, int(not(i and j)), int(not(i or j)),str(nn(i,j,v))+"  │ ",sep="  │ ")
47.
48. print("└────┴────┴────┴────┴────┴────┴────┘")
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.

Top