일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- inorder
- 자료구조
- mglearn
- vscode
- cudnn
- 머신러닝
- 웹 용어
- postorder
- 재귀함수
- 대이터
- web 사진
- html
- broscoding
- discrete_scatter
- classification
- KNeighborsClassifier
- web 개발
- 데이터전문기관
- C언어
- Keras
- java역사
- tensorflow
- bccard
- web
- CES 2O21 참여
- paragraph
- 결합전문기관
- pycharm
- web 용어
- CES 2O21 참가
- Today
- Total
목록[AI]/python.Neural_Network (6)
bro's coding
# soft max and cross entropy import numpy as np from sklearn.datasets import load_iris # data 준비 iris=load_iris() X=iris.data y=iris.target # one hot incoding onehot_y=np.eye(3)[y] # 초기화 w=np.random.randn(4,3) b=np.random.randn(3) # learning rate lr=0.001 def softmax(t): return np.exp(t)/np.sum(np.exp(t),axis=1).reshape(-1,1) pred_y=softmax(X@w+b) cross_entropy = -(onehot_y*np.log(pred_y+1e-7))...
import numpy as np from sklearn.datasets import load_iris # data 준비 iris=load_iris() x = iris.data[:,2] y = iris.data[:,3] # 초기화 w = np.random.randn()/10 b = np.random.randn()/10 # learning rate 설정 lr = 0.05 pred_y = x*w + b mse = np.mean((y-pred_y)**2) costs = [mse] for i in range(3000): pred_y = x*w + b dw = lr*2/len(y)*np.sum((y-pred_y)*x) db = lr*2/len(y)*np.sum(y-pred_y) w_new = w + dw b_ne..
data : iris X : iris.data y : iris.target w : random.randn 중간층의 활성함수 : sigmoid - 중간층 뉴런 10개를 포함해 y 값 분류하기. import numpy as np from sklearn.datasets import load_iris # data 준비 iris=load_iris() X=iris.data y=iris.target w=np.random.randn(4,10) b=np.random.randn(10) def sigmoid(t): return 1/(1+np.exp(-t)) u=sigmoid(X@w+b) ww=np.random.randn(10,3) bb=np.random.randn(3) def softmax(t): return np.exp(..
data : iris X : iris.data[:,[0,1,2]] y : iris.data[:,3] w : random.randn 중간층의 활성함수 : Relu - 중간층 뉴런 10개를 포함해 y 값 추정하기. import numpy as np from sklearn.datasets import load_iris X=iris.data[:,[0,1,2]] y=iris.data[:,3] w=np.random.randn(3,10) b=np.random.randn(10) # Relu 적용 u=np.maximum(0,X@w+b) ww=np.random.randn(10,1) b=np.random.randn(1) pred_y=u@ww+b pred_y array([[-13.68528237], [-11.99422824]..
import numpy as np import matplotlib.pyplot as plt x=np.arange(-10,10,0.1) y=np.tanh(x) import matplotlib.pyplot as plt plt.title('tanh(x)') plt.plot(x,y) x=np.arange(-10,10,0.1) x_copy=x.copy() x_copy x_copy[x_copy
data : breast cancer data[0,1] cost : BCE(binary cross entropy) import numpy as np import matplotlib.pyplot as plt # data 준비 from sklearn.datasets import load_breast_cancer cancer=load_breast_cancer() X=cancer.data[:,[0,1]] # normalization X_norm=(X-X.mean(axis=0))/X.std(axis=0) y=cancer.target # 초기화(random값을 사용해도 좋음) w=np.array([1,1]) b=0 # check 변화량의 크기 c=0.1 # cost 기록 cost_log=[] # 결과값을 확률로 바..