일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- django
- pymssql
- M2M
- Python
- windows10
- vscode
- tensorflow
- rs422
- 파이썬
- 장고
- Visual Studio Code
- 티스토리 초대장
- Serial
- c#
- rs485
- MEAN Stack
- matplot
- 자본주의
- scrapy
- sql developer
- MSSQL
- 텐서플로우
- 딥러닝
- MSSQL PYTHON
- oracle
- 윈도우10
- 오라클
- MX Component
- 크롤링
- PYTHON MSSQL
Archives
- Today
- Total
안까먹을라고 쓰는 블로그
[Python과 텐서플로우를 활용한 딥러닝 기본 향상과정] 3일차 본문
반응형
http://acornedu.co.kr/incumbent/edu_detail.jsp?seq=77
교육기간 : 10/12, 10/19, 10/26, 11/2, 11/9 (매주 토요일)
교육시간 : 09:30 ~ 17:30 (중식 12:30 ~ 13:30) [총 35시간]
교육장소 : HBI 기술연구소 에이콘 아카데미 종로학원 (서울특별시 중구 다동88 동아빌딩15층)
강사 : 전성일
통계&확률에 대한 지난 시간 교육 리뷰
미분
- 미분계수 (differential coefficient) - 순간 변화율, 접선의 기울기, 특정지점의 기울기
tensorflow설치
https://www.tensorflow.org/install/pip
Windows CMD창에서 아래의 명령어 실행하여 tensorflow 설치
pip3 install --user --upgrade tensorflow == 1.14
Microsoft Windows [Version 10.0.18362.418]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\yawns>pip3 install --user --upgrade tensorflow==1.14
Collecting tensorflow==1.14
Downloading https://files.pythonhosted.org/packages/f7/08/25e47a53692c2e0dcd2211a493ddfe9007a5cd92e175d6dffa6169a0b392/tensorflow-1.14.0-cp37-cp37m-win_amd64.whl (68.3MB)
|████████████████████████████████| 68.3MB 6.4MB/s
Requirement already satisfied, skipping upgrade: numpy<2.0,>=1.14.5 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (1.17.3)
Requirement already satisfied, skipping upgrade: google-pasta>=0.1.6 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (0.1.7)
Requirement already satisfied, skipping upgrade: wheel>=0.26 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (0.33.6)
Collecting tensorboard<1.15.0,>=1.14.0
Downloading https://files.pythonhosted.org/packages/91/2d/2ed263449a078cd9c8a9ba50ebd50123adf1f8cfbea1492f9084169b89d9/tensorboard-1.14.0-py3-none-any.whl (3.1MB)
|████████████████████████████████| 3.2MB 6.4MB/s
Requirement already satisfied, skipping upgrade: grpcio>=1.8.6 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (1.24.3)
Requirement already satisfied, skipping upgrade: gast>=0.2.0 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (0.2.2)
Requirement already satisfied, skipping upgrade: protobuf>=3.6.1 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (3.10.0)
Requirement already satisfied, skipping upgrade: termcolor>=1.1.0 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (1.1.0)
Requirement already satisfied, skipping upgrade: absl-py>=0.7.0 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (0.8.1)
Requirement already satisfied, skipping upgrade: keras-preprocessing>=1.0.5 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (1.1.0)
Requirement already satisfied, skipping upgrade: six>=1.10.0 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (1.12.0)
Collecting tensorflow-estimator<1.15.0rc0,>=1.14.0rc0
Downloading https://files.pythonhosted.org/packages/3c/d5/21860a5b11caf0678fbc8319341b0ae21a07156911132e0e71bffed0510d/tensorflow_estimator-1.14.0-py2.py3-none-any.whl (488kB)
|████████████████████████████████| 491kB ...
Requirement already satisfied, skipping upgrade: keras-applications>=1.0.6 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (1.0.8)
Requirement already satisfied, skipping upgrade: astor>=0.6.0 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (0.8.0)
Requirement already satisfied, skipping upgrade: wrapt>=1.11.1 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorflow==1.14) (1.11.2)
Requirement already satisfied, skipping upgrade: werkzeug>=0.11.15 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorboard<1.15.0,>=1.14.0->tensorflow==1.14) (0.16.0)
Collecting setuptools>=41.0.0
Downloading https://files.pythonhosted.org/packages/6a/9a/50fadfd53ec909e4399b67c74cc7f4e883488035cfcdb90b685758fa8b34/setuptools-41.4.0-py2.py3-none-any.whl (580kB)
|████████████████████████████████| 583kB 6.4MB/s
Requirement already satisfied, skipping upgrade: markdown>=2.6.8 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from tensorboard<1.15.0,>=1.14.0->tensorflow==1.14) (3.1.1)
Requirement already satisfied, skipping upgrade: h5py in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from keras-applications>=1.0.6->tensorflow==1.14) (2.10.0)
Installing collected packages: setuptools, tensorboard, tensorflow-estimator, tensorflow
WARNING: The scripts easy_install-3.7.exe and easy_install.exe are installed in 'C:\Users\yawns\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script tensorboard.exe is installed in 'C:\Users\yawns\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts freeze_graph.exe, saved_model_cli.exe, tensorboard.exe, tf_upgrade_v2.exe, tflite_convert.exe, toco.exe and toco_from_protos.exe are installed in 'C:\Users\yawns\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed setuptools-41.4.0 tensorboard-1.14.0 tensorflow-1.14.0 tensorflow-estimator-1.14.0
python에서 아래코드 실행
import tensorflow as tf;
print(tf.reduce_sum(tf.random.normal([1000, 1000])))
아래와 같은 결과 값이 나오면 설치 성공
tf.Tensor(-802.1695, shape=(), dtype=float32)
matplotlib설치
C:\Users\yawns>pip install matplotlib
Collecting matplotlib
Downloading https://files.pythonhosted.org/packages/1a/c0/69e3f695d7384012e90be1e16570c08953baae00fd98094179ef87c7d5a2/matplotlib-3.1.1-cp37-cp37m-win_amd64.whl (9.1MB)
|████████████████████████████████| 9.1MB 3.2MB/s
Collecting cycler>=0.10
Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting python-dateutil>=2.1
Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
|████████████████████████████████| 235kB 6.4MB/s
Requirement already satisfied: numpy>=1.11 in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from matplotlib) (1.17.3)
Collecting kiwisolver>=1.0.1
Downloading https://files.pythonhosted.org/packages/c6/ea/e5474014a13ab2dcb5056608e0716c600c3d8a8bcffb10ed55ccd6a42eb0/kiwisolver-1.1.0-cp37-none-win_amd64.whl (57kB)
|████████████████████████████████| 61kB 3.8MB/s
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1
Downloading https://files.pythonhosted.org/packages/11/fa/0160cd525c62d7abd076a070ff02b2b94de589f1a9789774f17d7c54058e/pyparsing-2.4.2-py2.py3-none-any.whl (65kB)
|████████████████████████████████| 71kB 4.5MB/s
Requirement already satisfied: six in c:\users\yawns\appdata\local\programs\python\python37\lib\site-packages (from cycler>=0.10->matplotlib) (1.12.0)
Requirement already satisfied: setuptools in c:\users\yawns\appdata\roaming\python\python37\site-packages (from kiwisolver>=1.0.1->matplotlib) (41.4.0)
Installing collected packages: cycler, python-dateutil, kiwisolver, pyparsing, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.1.1 pyparsing-2.4.2 python-dateutil-2.8.0
numpy 버전 낮추기 (tensorflow 사용 시, numpy관련 에러메세지 표시 시 적용)
pip install "numpy<1.17"
# Tensorflow - Linear Regression
import tensorflow as tf
#import tensorflow.compat.v1 as tf
#tf.disable_v2_behavior()
import matplotlib.pyplot as plt
# x_data (5, 3)
x_data = [[90, 85, 87],
[80, 75, 91],
[70, 68, 79],
[85, 90, 88],
[95, 94, 92]]
# y_data (5, 1)
y_data = [[85],
[87],
[74],
[86],
[93]]
# placeholder - 변수 생성 - 값을 나중에 입력하고 싶으면, placeholder를 쓰
X = tf.placeholder(tf.float32, shape = [None,3])
Y = tf.placeholder(tf.float32, shape = [None,1])
# Variable - 변수지정
W = tf.Variable(tf.random_normal([3,1]), name = 'Weight')
b = tf.Variable(tf.random_normal([1]), name = 'Bias')
h = tf.matmul(X, W) + b
# reduce_mean <https://webnautes.tistory.com/1235>
# reduce_mean - 평균을 내주는 메서드
# square - 제곱을 해주는 메서
cost = tf.reduce_mean(tf.square(h - Y)) # 코스트 함수
# Gradient Descent Algorithm (경사 하강 알고리즘)
# 임의의 점에서 시작하여 변수(W, b)를 조금 씩 변경하여 Cost값을 최소로 줄이는 경사로(기울기) 값을 파악
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.00001) # 학습 최적화
# optimizer 미분해주는 함 (경사도를 구함)
train = optimizer.minimize(cost) # 코스트 최소화
# 세션 생성 및 초기화
sess = tf.Session() # Session() 객체화
sess.run(tf.global_variables_initializer()) # Variable 초기
for step in range(1000):
cost_value, w_value, b_value, _ = sess.run([cost, W, b, train], {X: x_data, Y: y_data}) # 학습
print(step, cost_value, w_value, b_value)
#=================================================================
print("h : ", sess.run(h, feed_dict = {X:[[90, 85, 83]]}))
# train = (tf.train.GradientDescentOptimizer(learning_rate=0.1)).minimize(tf.reduce_mean(tf.square((X * W + b) - Y)))
# https://blog.naver.com/hanovation/221568451580
https://webnautes.tistory.com/1235
https://blog.naver.com/hanovation/221568451580
3. Classfication
3.1 Logistic Function
3.2 Logistic Classfication
3.3 Softmax Classfication
반응형
'Language > Python' 카테고리의 다른 글
[Python과 텐서플로우를 활용한 딥러닝 기본 향상과정] 4일차 - Source (0) | 2019.11.02 |
---|---|
[Python과 텐서플로우를 활용한 딥러닝 기본 향상과정] 4일차 (0) | 2019.11.02 |
[Python] 모두의 데이터분석 with 파이썬 - 코드2 (matplot) (0) | 2019.10.21 |
[Python] 모두의 데이터분석 with 파이썬 - 코드2 (인구통계데이터 + matplot) (1) | 2019.10.21 |
[Python] 모두의 데이터분석 with 파이썬 - 코드1 (인구통계데이터 + matplot) (0) | 2019.10.21 |
Comments