일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- web
- cudnn
- web 개발
- classification
- Keras
- broscoding
- 머신러닝
- inorder
- bccard
- paragraph
- discrete_scatter
- CES 2O21 참여
- KNeighborsClassifier
- web 사진
- 대이터
- C언어
- 결합전문기관
- pycharm
- mglearn
- 웹 용어
- 재귀함수
- postorder
- java역사
- vscode
- web 용어
- 데이터전문기관
- CES 2O21 참가
- html
- tensorflow
- 자료구조
- Today
- Total
목록[AI] (189)
bro's coding
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/cUImnt/btqD4U8JQA9/6oVk2i1muLgPs8PBxFbKh1/img.png)
sess=tf.InteractiveSession() X=tf.constant([1,2],dtype=tf.float32) y=tf.constant([3,5],dtype=tf.float32) w=tf.Variable(tf.random.normal([])) b=tf.Variable(tf.random.normal([])) tf.global_variables_initializer().run() pred_y=X*w+b mse=tf.reduce_mean(tf.square(y-pred_y)) dw=2*tf.reduce_mean(X*(y-pred_y)) db=2*tf.reduce_mean(y-pred_y) learning_rate=.001 op1=tf.assign(w,w+learning_rate*dw) # variabl..
행렬곱 sess=tf.InteractiveSession() tf.matmul([[1,2]],[[3],[4]]).eval() array([[11]]) 전치행렬 a=tf.constant([[1],[2]]) tf.transpose(a).eval() array([[1, 2]])
# 설계 a=tf.constant(2) b=tf.Variable(3) c=a*b # 실행 with tf.Session() as sess: sess.run(b.initializer) n=sess.run(c) print(n) # with를 사용하면 꿀기능이 있다. with tf.Session() as sess: b.initializer.run() # operation (동작 지시) n=c.eval()# tensor (값) print(n) # with 안에서는 어떤 session을 이야기하는지 알 수 있어서 위와 같이 사용 할 수 있다. # with 밖에서 사용하려면 interactiveSession()을 사용 a=tf.constant(2) b=tf.Variable(3) c=a*b sess=tf.Interac..
import numpy as np import tensorflow as tf tensorflow에서의 data type - tf.constant() - tf.Variable() - tf.placeholder() tf.constant() # 상수 - 학습률 등 고정된 값 tf.Variable() # 변수 - 가중치(w)와 절편(b) tf.placeholder() # 플레이스 홀더 - X값 등 > constant a=tf.constant(2) b=tf.constant(3) display(a,b) c=a*b display(c) sess=tf.Session() display(sess.run(c)) sess.run([a,b,c]) sess.close() 6 [2, 3, 6] > Variable a=tf.const..
# python 3.6 version 기준 1.12.0 version이 호환이 잘 됨 # anacoda를 관리자 권한으로 실행 후 아래 명령어 입력 pip install tensorflow==1.12.0 # 잘 되었나 확인하는 방법 import tensorflow as tf
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/NuRBH/btqD2v1XjEj/We8XaECsyPybCOplsaNSc0/img.png)
# 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))...
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bLX2Tr/btqDWrG7shn/0T25Znpi0jWFy9GAllCkSk/img.png)
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]..