1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import numpy as np
 
from matplotlib.image import  imread
 
def abcd():
    img = imread("./abc.png")
 
    plt.show()
 
 
def abc():
    A=np.array([13])
    B=np.array([32])
 
    data=np.arange(10)
    plt.show()
 
def abc1():
    x = np.arange(060.1)
 
    y = np.sin(x)
 
    plt.show()
 
def flatten():
    A = np.array([[5155], [1419], [04]])
 
    D = A.flatten()
 
    print(D)
    print(D[np.array([024])])
    print(D > 15)
    print(D[D > 15])
 
def abc2():
    x = np.arange(060.1)  # 0에서 6까지 0.1 간격으로 생성
 
    y1 = np.sin(x)
    y2 = np.cos(x)
 
    plt.plot(x, y2, linestyle="--", label="cos")  # cos함수는 점선으로 그리기
 
    plt.xlabel("x")  # x축 이름
    plt.ylabel("y")  # y축 이름
    plt.title("sin & cos")  # 제목
    plt.legend()
    plt.show()
 
 
if __name__ == "__main__":
    abc()
    abc1()
    flatten()
    abc2()
    abcd()
 
  tp://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import numpy as np
 
def AND(x1, x2):
    x = np.array([x1, x2])
 
    w = np.array([0.50.5])
    b = -0.7
    tmp = np.sum(w * x) + b
    if tmp <= 0:
        return 0
    else:
        return 1
 
def NAND(x1, x2):
    x = np.array([x1, x2])
 
    w = np.array([-0.5-0.5])
    b = 0.7
    tmp = np.sum(w * x) + b
    if tmp <= 0:
        return 0
    else:
        return 1
 
def OR(x1, x2):
    x = np.array([x1, x2])
 
    w = np.array([0.50.5])
    b = -0.2
    tmp = np.sum(w * x) + b
    if tmp <= 0:
        return 0
    else:
        return 1
 
def XOR(x1, x2):
    s1 = NAND(x1, x2)
 
    s2 = OR(x1, x2)
    y = AND(s1, s2)
 
    return y
 
if __name__ == "__main__":
    for xs in [(00), (10), (01), (11)]:
        y = XOR(xs[0], xs[1])
        print(str(xs) + " -> " + str(y))
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
import numpy as np
 
def step_function(x):
    return np.array(x>0, dtype=np)
 
 
 
= np.arange(-5.05.00.1)
= step_function(X)
plt.ylim(-0.11.1)
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

+ Recent posts