This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pylab as plt | |
| #implement step function/ 입력이 0을 넘으면1, 그 외에는 0을 출력 | |
| def step_function(x): | |
| if x>0: | |
| return 1 | |
| else: | |
| return 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Initialize 'AND logic' function | |
| def AND(x1,x2): # x1, x2를 인수로 받는 AND함수 | |
| w1, w2, theta=0.5,0.5,0.7 #매게변수 초기화 | |
| tmp = x1*w1+x2*w2 #가중치를 곱한 입력의 총합이 임계값을 넘으면 1 반환, 나머지 0 반환 | |
| if tmp <= theta: | |
| return 0 | |
| elif tmp > theta: | |
| return 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #matplotlib: 그래프를 그려주는 라이브러리 | |
| #단순한 그래프 그리기 | |
| import numpy as np | |
| import matplotlib.pyplot as plt #matplotlib의 pyplot모듈 이용 | |
| #데이터 준비 | |
| x=np.arange(0,6,0.1) #0에서 6까지 0.1간격으로 생성 | |
| y=np.sin(x) #sin함수 적용해 y에 할당 | |
| #그래프 그리기 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 넘파이 가져오기 | |
| import numpy as np | |
| #넘파이 배열 생성 | |
| x = np.array([1.0,2.0,3.0]) | |
| print(x) | |
| #[1, 2, 3] | |
| type(x) | |
| #<class 'numpy.ndarray> | |
| #np.arry: 리스트 인수, 넘파이 배열(numpy.ndarray) 반환 |