Lab 00 - TensorFlow의 설치 및 기본적인 Operation

 


1. TensorFlow

  • Open source software library for Numerial computation using data flow graphs.
  • Python

2.  Data Flow Graph

  • Nodes : mathermatical operations
  • Edges : multidimensional data arrays (tensors) communicated between them.

3. Check installation and version    (1.4)

 

 

4. Example

 

  1) Hello world

 

  2) Node Add 

 

  3) Placeholder

 

 

 

 

 

 

TensorFlow Mechanics 

 

1. Build graph using TensorFlow operations

2. feed data and run graph (operation) : sess.run(op)

3. update variables in the grap (and return values)

 

 

 

4. Tenor Ranks, Shapes, and Types

  1) Rank

  2) Shape

  3) Type

 

 

 

Lab 02 - TensorFlow로 구현한 Linear regression

 

1. Example

 

2. Linear Regression with Placeholder

 

 

 

 

Lab 03 - Linear regression : minimize Cost

 

 

1. plot cost function

 

 

2. Optimized by Hand

 

 

3. Optimized by Gradientdecent Function

 

4. Calculate gradient value

 

 

 

 

Lab 04 - multi-variable Linear regression

 

1. Multi-Variable  

 

 

2. Multi-Variable with matrix

 

 

 

3. Slice Matrix

 

 

4. file data

 

 

5. Queue Runners

 

 

 

[에러 발생함]  일단 진행

 

 

 

 

 

Posted by 꿈을펼쳐라
,

강의 웹사이트: http://hunkim.github.io/ml/

Facebook: https://www.facebook.com/groups/Tenso...

소스코드: https://github.com/hunkim/DeepLearnin...

 

 

Lec 00 - Machine/Deep learning 수업의 개요와 일정



 

Lec 01 - 머신러닝의 개념과 용어

 

1. Machine Learning

  - "Field of study that gives computers the ability to learn without being explicitly programmed” Arthur Samuel (1959)

 

2. Supervised/Unsupervised learning

  - Supervised learning:

     . learning with labeled examples

  - Unsupervised learning: un-labeled data

     . Google news grouping

     . Word clustering

 

3. Types of supervised learning

  • Predicting final exam score based on time spent

    - regression

  • Pass/non-pass based on time spent

    - binary classification

  • Letter grade (A, B, C, E and F) based on time spent

    - multi-label classification



Lec 02 - Linear Regression의 Hypothesis 와 cost 설명

1. Linear hypothesis

    H(x) = W x + b

 

2. Cost

    H(x) - y

  

 

     H(x) = W x + b

 

   

 

  3. Goal : Minizie Cost

 

      minimize cost(W,b)

 

 

 

Lec 03 - Linear Regression의 cost 최소화 알고리즘 설명

 

1. Hypothesis and Cost

  • H(x) = W x

        

 

 2. Gradient descent algorithm Minimize cost function

  • formal definition

        

  • How about Newton-Rapshon algorithm ?

 

 3. Derivative Calculator : [link]

 

 4. Check cost function 

  • must be convex curve

 

Lec 04 - Multi-variable linear regression

 

1. Hypothesis for multi-variable

 

   

 

2. Hypothesis using Matrix

    

    

 

 

Posted by 꿈을펼쳐라
,

I. 아나콘다 설치하기

 

아아콘다 홈페이지 (https://www.anaconda.com/download/)에 접속해서 최신의 아나콘다 버전을 다운받아 설치한다.   (2017/11/26일 현재, Anaconda 5.0.1 버전이 최신)

 

 

 

 

PATH 환경변수 추가는 이전 설치된 버전보다 먼저 적용되도록하지만, 재설치 및 제거시 문제를 야기시킬 수 있으니 추천하지 않는단다... 일단 빨간색이니 선택하지 않고 진행..

 

 

대신에, Anaconda 전용  Prompt 환경에서 시작하는 아이콘이 제공되므로 굳이 Path 추가할 필요가 없단다..

 

 

 


 

 

 

II. TensorFlow 설치

 

   TensorFlow 홈페이지(https://www.tensorflow.org/install/)에 설치 방법이 자세히 설명되어 있다. 

 

 

CPU기반과 GPU기반의 텐서 플로우 설치 방업을 안내해 주고 있는데, 거금을 주고 장만한 1080이니 GPU모드로 설치를 진행해야지...  

 

 

하지만, 갑자기 발동된 실험 정신과, 약간의 실수로 다양한 테스트와 실패를 경험하였다.

 

 

GPU 기반의  Tensorflow을 설치하기 위해서는 사전에 설치해야할 것이 있다.

 

 

1. CUDA Tool Kit 설치 (GPU ) 

 

      - CUDA Toolkit Download 페이지 : https://developer.nvidia.com/cuda-downloads     

      -  홈페이지에 링크된 최신 버전 9.0을 설치할 경우, dll을 찾지 못하는 에러가 발생함 

      - TensorFlow을 사용하기 위해서는 CUDA Tool Kit 8.0이 설치되어한다.

  

 

바로 다운을 진행하면 최신 버전(2017.11.27 현재, 9.0 버전)을 받게되고 이렇게되면 TensorFlow의 현재 버전은 에러가 발생된다. 

 

 

이 화면을 보기 싫다면, Tensorflow 소스를 받아서 다시 컴파일 하시던가 (설마요..), 위의 다운로드 페이지 하단에 "Legacy Release" 페이지로 이동한다.

 

각 버전별로 링크가 되어 있는 이 페이지에서 설치 가이드에서 소개하고 있는 CUDA Toolkit 8.0의 최신 Patch 버전으로 이동한다.

 

 

그리고, OS, Version, Installer Type을 선택하고, Base Installer와 Patch2 버전을 각각 다운받아 설치 한다.

 

 

CUDA Toolkit 8.0을 설치할 때, 아래와 같은 경고가 나오지만 무시하고 진행.

 

 

 

        

2. cuDNN v6.1. 설치

 

      - cuDNN 다운로드 페이지 : https://developer.nvidia.com/rdp/cudnn-download 

      - 계속 다운을 받으려면 NVIDIA Developer 회원가입을 해야 함.

      - 이전에 설치한 CUDA Tool Kit 8.0에 해당하는 6.0 버전을 선택하고

 

 

- OS에 해당하는 버전을 선택하여 다운 받는다.

 

 

- cuDNN은 zip으로 압축되어 있고, 특정 디렉토리에 압축을 풀고, 해당 파일을 이전에 설치했던 CUDA Toolkit을 설치한 디렉토리에 덮어 쓴다. 

 

 

- 내 경우는  "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"에 덮어썼다.

 

 

3. Tensorflow 설치하기

 

    이제 마지막 단계, Tensorflow를 설치해보자.   

    먼저, 아나콘다를 실행하기 위해서 시작>Ananconda3 (64bit)를 선택하여 실행창을 연다. 

 

 

 

1)  conda 환경을 생성

(여기서 TF는 임의 환경명이고, 3.6은 설치된 python의 버전이다.  가이드에서는 3.5로 되어 있음) 

(C:\ProgramData\Anaconda3) C:\Users\rgba> conda create -n TF python=3.6

 

 

 

2)  TF 환경 활성화

 

(C:\ProgramData\Anaconda3) C:\Users\rgba> activate TF

 

 

 

3)  tensorflow 설치 

 

(TF) C:\Users\rgba> pip install --ignore-installed --upgrade tensorflow-gpu

 

 

 

 

 


 

 

Ⅲ. TensorFlow 설치

 

 

실행창에서 python을 실행하고

 

 

(TF) C:\Users\rgba> python

 

아래와 같이 python 스크립트를 작성하고

  

 

>>> import tensorflow as tf

>>> hello = tf.constant('Hello, TensorFlow!') 

>>> sess = tf.Session()

>>> print(sess.run(hello)

 

실행하면 아래와 같은 결과를 확인.. 

 

Hello, TensorFlow! 

 

 

 

수고 많으셨습니다.~~~~~~

 

 

 

 

PS.. 이것 저것 해보다 보니 설치버전을 삭제해야할 경우가 있었다.  혹시 그럴 경우 참고..

 

 

 pip 설치 패키지 삭제   

 

pip uninstall [package name]

 

conda create 삭제  

 

conda clean --all 
Posted by 꿈을펼쳐라
,