TensorFlow - Logistic regression
 

Logistic regression 

- Binary Classpication 을 학습한다는 것은 0 과 1을 분류하는 선을 학습하는 것이다.

- X 라는 입력이 있고 W 계산을 지나면 Z라는 값이 나오고...
이 값을 Sigmoid 함수에 통과시키면 Y햇 (H(X)) 가 나온다. (얘는 0과 1 사이의 값)

- Y가 실 데이터 결과값 Y햇은 추론한 데이터 결과값






Multinomial Classification  - 라벨이 여러개인 녀석


Softmax Regression - 위의 Multinmial Classfication 을 분석하는 기법.

2진의 Logistic Regression 과는 달리 A,B,C 등의 라벨링이 된다.

MultiVariable Regression 과 마찬가지로 matrix 를 사용한다.



Hypothesis 과정에서 softmax 사용시, 추론에 대한 확률 값이 나오게 된다.
A : 0.7, B : 0.1, C : 0.2 = 1.0 요런식으로....


여기서 One.Hot.Encoding 기법을 통하여 가장 높은 수만 1로 두고 나머지는 0으로 둔다.

 





TensorFlow - Hypothesis, CostFunction

범위
(가설 추론)
  • y=f(x)

  • 오차 : Cost
  • Cost Function 이 0이 되야 한다.

Hypothesis 하이포시시스
  • data set 의 입력값, data set 의 출력값 


Cost Function 
  • x 가 입력값 y 가 실제 결과값인데
  • H(x) 는 예측한 값
  • 결과값이 음수일 수도 있음
  • (H(x)-y)^2
    • 제곱을 한다.
    • 제곱을 하는 이유
      • W를 구할 때 미분하여 기울기가 0인것을 찾으면 됨, (알고리즘에서)
      • 음수를 없애ㅣ 위함.

  • 시그마로 표현.
  • cost 가 0에 수렴하는 W,b 를 구하는것이 목표



그레디언트 가 0이 되도록 한다. (데이터셋을 많이 넣어서)


기울기 최소값 알고리즘
  • 미분 - 기울기를 구한다.
  • 적분 - 넓이를 구한다.









Tensorflow 기초 - Window 에서 사용하기


Leaner Regression 에 대한 CostFunction
     

 

Tensorflow - TensorBoard
  • Tensorflow 에 기록된 로그를 시각화하여 보여주는 도구
  • 로그를 시각화하는 것이기 때문에 이전 로그 기록도 그대로 시각화 해준다.

Jupyter 에서 설치


Trouble Shooting
  • Check that jupyter-tensorboard, tensorflow and tensorboard are all installed via pip list|grep tensor, you should see at least three lines, jupyter-tensorboard, tensorflow and tensorflow-tensorboard (or tensorboard ). And also, check that tensorflow version is >=1.3.
  • Check that jupyter notebook is installed in the same python version via pip list|grep notebook, you shold see notebook package.
  • If you have installed the package but no buttons of tensorboard in jupyter appear, you need to run jupyter tensorboard enable --user. The step should be performed in the installation process, however, in some cases it seems that the command is not executed.
  • Checking for error messages in the browser's Javascript console (e.g. CTRL+SHIFT+J in Chrome).
  • Check the issue page for this repository. If you can't find one that fits your problem, please create a new one!
  • https://stackoverflow.com/questions/46499808/pip-throws-typeerror-parse-got-an-unexpected-keyword-argument-transport-enco
    • jupyter-tensorboard 가 설치가 안되어 있어서 설치하는데 오류가 발생함.
      • conda install -c conda-forge keras 명령어 실행 중
      • 안될 경우 pip/index.py 파일 수정 필요  730 라인

TensorBoard
  • 노트북의 running 탭에 instance가 하나씩 생김.

TensorBoard 코드
  • 로그 지정
    • writer = tf.summary.FileWriter('./board/sample_2', sess.graph)




AdamOptimizer
  • Gradient Descent Optimization Algorithms 의 한 종류
  • Adam (Adaptive Moment Estimation)은 RMSProp과 Momentum 방식을 합친 것 같은 알고리즘이다. 이 방식에서는 Momentum 방식과 유사하게 지금까지 계산해온 기울기의 지수평균을 저장하며, RMSProp과 유사하게 기울기의 제곱값의 지수평균을 저장한다.
  • 출처 - http://shuuki4.github.io/deep%20learning/2016/05/20/Gradient-Descent-Algorithm-Overview.html
















+ Recent posts