1. What Scrum is .

  ㄱ. 프로젝트관리를 위한 상호,점진적 개발방법론이며, 애자일 소프트웨어 공학 중의 하나로 소프트웨어 개발 프로젝트를 위하여 고안되었지만, 소프트웨어 유지보수 팀이나 일반적인 프로젝트/프로그램 관리에서도 적용될 수 있다. 

  ㄴ. 일을 처리하기 위한 하나의 단위 조직 

   


2. Scrum Methodology

 1) SPRINT 

   ㄱ. SCRUM 팀을 구성하고 업무를 해결하기 위한 반복적 활동의 하나의 단위

   ㄴ. 1주~4주를 하나의 SPRINT 시간 단위로 인식

   ㄷ. 



 1) 주요구성원

   ㄱ. Dev. Team (Cross Functional Team) 

      . 7±2명

      . 개발, 디자인, 테스트, QA 등을 실시하는 팀 

   ㄴ. Product Owner  

      . ROI (Return On Investment)

      . PBI (Product Back Log Item) :  요구사항 우선순위 관리 

      . 1개 Product는 1개 PO임 

   ㄷ. Scrum Master

      . 팀이 잘 운영되고 생산적이 되도록 노력함


  2) 주요 활동 

    ㄱ. Sprint Planning 

       . Part 1 : What 무엇을 할 것인가를 결정 (우선순위)  1~4hr 

       . Part 2 How, How many 어떻게 할 것인가를 결정 

       . SPRINT GOAL

       . COMMITMENT

       . FORECAST 예측을 하지 않음 -> 경험적 학습을 통해 실험, 확인

    ㄴ. REFINEMENT 

       . SPRINT에서 수행할 내용을 5~10% 내외로 세분화 한다. 

    ㄷ. DSM (DAILY SCRUM MEETING) 

       . 15min 내외 

       . 한일/할일/장애물을 각자 팀원들과 공유

    ㄹ. PSPI (Potential Shippable Product Increment)

       . SPIRNT의 결과물

       . 검증가능한 프로덕트 (실행가능한 프로그램)

       . Sprint Review 대상 

    ㅁ. Sprint Review 

       . Sprint 산출물에 대한 리뷰 

       . 제품 

       . 1~4hr 

    ㅂ. Sprint Retrospective 

       . TEAM Process 에 대한 회고 

       . 1~4hr




       



Posted by 꿈을펼쳐라
,

교육명 : Agile 기반의 일하는 방식 혁신 과정 

일   자 : 2018.05.02 ~ 05.03 (2일간)

장   소 : 본사 



[1일차 교육 내용]

1. 3 Key-Words Meeting : Ice Breaking 도구

  1) 좋아하는 것, 최근에 배웠던 내용, 현재 나의 관심사 세가지 키워드를 카드에 적음 ( 레포츠, 스키, 드럼)

  2) 1:1 마주하고, 2분안에 자기와 상대의 소개를 진행함. (상대와의 거리는 마주앉은 자리에서 10cm 내외)

  3) 상대를 바꿔가며 ( 한쪽 자리 바꿈) 반복 진행 


  <Point : 집중을 만드는 환경>   

  1. TIME BOX : 2분이라는 시간적 제약 

  2. SHARED GOAL 

  3. TASK 

  4. 환경  - 1:1 , 거리, 음악 (Sound Masking)


2. 강사 소개 : 박진표 

  1) 독일에서 초등학교 졸업

  2) OOD-E 다국적 기업 소속

  3) 취미는 DJing 


   위의 항목중 2개는 진실이고, 1개는 거짓. 


<Point : 진진가> 

 1. 내성법 : 자기자신을 돌아보는 방식   

 2. 빌헤름 분트 : 현대 심리학의 아버지 

   1) 자신의 경험에 대한 주관적인 관찰, 자기의 내부 성찰법, Introspection   



3.  http://www.online-stopwatch.com : 회의시간 체크



4. 관지자 주도 개발 실습 

  1) 2인 1조 ( 1명 개발자, 1명 관리자)

  2) 준비 : 바닥에는 기하학적인 폴리곤이 테이블사이에 연결되어 있음.

  3) 목표 : 2분안에 보폭 60cm 기준으로 60 걸음 가는 것. 

  4) 관리자가 사용할 수 있는 프로토콜 

     ㄱ. 가, 멈춰, 좌로, 우로, 빠르게, 느리게  

  [결과] 10여개 팀중 목표를 달성한 팀은 1개 팀 


5. 자기주도 개발 실습 

  1) 관리자 전원 해고 

  2) 각자의 자율적으로 동일 목표를 실행  

  [결과] 모든 팀 목표 달성 


 

관리자 주도 

자기 주도 

 생산성

높지 않음 

높음 

 품질관리

어려움 

쉬움 

커뮤니케이션 비용

높다 

적다 

멈춤 

발생 

비발생 

개발자 자세 

수동적 

능동적 (프로세스에 대한 고민)

충돌 

자주발생 

자연스런 흐름 

기록

발생 

미발생 

관리자 부담

높음 

감소 

만족도 

낮음 

높음 


<자연스러운 흐름>

1. SHARED GOAL

2. 재량권

3. Fixed TEAM 

4. FEEDBACK - 투명한 정보




6. 부정적인 것, 하지말아야 할 것을 정리하는 것이 더 창의적일 수 있음.



7. 복잡도에 따른 Project 구분 

  

       단순 영역을 제외한 모든 분야에 Agile 적용 가능 

       단순 영역은 Waterfall 방식이 더 효율적임 


8. WaferFall 방식의 한계 

  1) 고객도 요구사항을 잘 모름

  2) 해당 프로젝트의 이해도가 가장 높은 시기는 현재이다.  ( 시간이 지날 수록 점진적으로 높아짐) 

  3) 프로젝트 초기에 모든 것을 예측할 수 없음 

  4) 개발 진행하면서 요구사항이 명확해 지는 것이 많음


   1. 요구사항 변경

   2. 세부사항은 개발 중 명확해짐

   3. 변경사항이 발생할 수 밖에 없음

   4. 오해   ( 고객 - 설계자 > 요구사항 문서 - 개발자 > 코딩 - 프로그램  ) 2번의 추상화 단계 발생

   5. 실수



9. Agile Manifesto (애자일 선언)

   1) 2001년 2월

   2) traditional 방법론 

       ㄱ. 사람은 도구      ㄴ. Know-How 가 중요 

   3) Agile 기법 

       ㄱ. Scrum : frame work

       ㄴ. XP : Extreme Programming 

       ㄷ. kanban : 방법론

       ㄹ. DSDM : Dynamic System Development Method

       ㅁ. FDD ( Feature Driven Development) 

       ㅂ. TDD  (TEST Driven Development)

       ㅅ. Crystal


[애자일 선언] 출처 : http://gyumee.egloos.com/1021784



애자일 선언을 위키백과와 애자일 선언 홈페이지의 내용을 참고하여 번역해 올립니다.


http://en.wikipedia.org/wiki/Agile_Manifesto

http://agilemanifesto.org/


---------------


애자일 선언은 애자일 소프트웨어 개발의 토대를 강화하는 원칙을 발표한 것이다. 초안은 2001년 2월 11일에서 13일까지 유타의 워새치산맥에 있는 스노우버드 스키 리조트 라운지에서 만들어졌다. 여기에서 기존의 무거운 방법론보다 가벼운 대체방법론들의 필요성에 대해 토의하고자 Extreme Programming, Scrum, DSDM, AdaptiveSoftware Development, Crystal, Feature Driven Development, Pragmaticprogramming 같은 다양한 새 방법론의 대표자들이 만났다.


---------------


Manifesto for Agile Software Development

애자일 소프트웨어 개발에 대한 선언


We are uncovering better ways of developing software by doing it and helping others do it.

우리는 소프트웨어를 개발하는 더 나은 방법을, 직접 실천하고 다른 이들을 도우면서 밝혀내고 있다.


Through this work we have come to value:

이 작업을 하는 동안 우리는 다음을 가치있게 여기게 되었다.


Individuals and interactions over processes and tools 

프로세스나 도구에 앞서 개인과 상호 작용을 

Working software over comprehensive documentation

포괄적인 문서화에 앞서 작동하는 소프트웨어를


Customer collaboration over contract negotiation

계약 협상에 앞서 고객과의 협력을 


Responding to change over following a plan

계획 준수에 앞서 변화에 대한 대응을


That is, while there is value in the items on the right, we value the items on the left more.

우리는 왼쪽 항목의 가치를 인정하면서도 오른쪽 항목을 더 중요하게 여긴다.


Kent Beck, Mike Beedle, Arie van Bennekum,

Alistair Cockburn, Ward Cunningham, Martin Fowler,

James Grenning, Jim Highsmith, Andrew Hunt,

Ron Jeffries, Jon Kern, Brian Marick,

Robert C. Martin, Steve Mellor, Ken Schwaber,

Jeff Sutherland, Dave Thomas


-----------------------------------------------------------------------------------

Principles behind the Agile Manifesto

애자일 선언의 배경 원칙들


We follow these principles:

우리는 다음 원칙들을 따른다:


Our highest priority is to satisfy the customer through early and continuous delivery of valuable software.

가치있는 소프트웨어를 조기에 그리고 지속적으로 인도해 고객을 만족시키는 것을 가장 우선으로 여긴다.


Welcome changing requirements, even late in development. Agile processes harness change for the customer's competitive advantage.

개발 후반이라고 해도 요구사항의 변경을 환영한다. 애자일 프로세스는 변경을 고객의 경쟁적 우위 요인으로 삼는다.


Deliver working software frequently, from a couple of weeks to a couple of months, with a preference to the shorter timescale.

작동하는 소프트웨어를 수 주에서 수 개월의 주기로 자주, 가능한 더 짧은 기간에 인도한다.


Business people and developers must work together daily throughout the project.

프로젝트 기간 내내 업무 전문가와 개발자가 매일 함께 일해야 한다. 


Build projects around motivated individuals. Give them the environment and support they need, and trust them to get the job done.

동기부여된 개인을 중심으로 프로젝트를 구축하라. 그들에게 필요한 환경과 지원을 제공하고 업무를 완수할 것으로 믿어라.


The most efficient and effective method of conveying information to and within a development team is face-to-face conversation.

개발팀에게 그리고 팀 내에서 정보를 전파하는 가장 효율적이고도 효과적인 방법은 얼굴을 직접 보고 대화하는 것이다.


Working software is the primary measure of progress. 

작동하는 소프트웨어가 진도를 측정하는 제 1 척도이다.


Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely. 

애자일 프로세스는 지속할 수 있는 개발을 장려한다. 후원자들과 개발자들과 사용자들은 일정한 보폭을 끝까지 유지할 수 있어야 한다.


Continuous attention to technical excellence and good design enhances agility.

기술적 탁월함과 좋은 설계에 대한 끊임없는 관심은 기민성을 강화한다.


Simplicity--the art of maximizing the amount of work not done--is essential.

단순함, 안 해도 되는 일은 최대한 안 하게 하는 기교, 이것이 핵심이다. 


The best architectures, requirements, and designs emerge from self-organizing teams.

최고의 아키텍쳐와 요구사항과 설계는 자기 조직화된 팀에서 나온다.


At regular intervals, the team reflects on how to become more effective, then tunes and adjusts its behavior accordingly.

팀은 정기적으로 더 효과적으로 일할 수 있는 방법을 숙고하고 그에 따라 자신의 행동을 조율하고 수정한다.


--------


2009/3/11 : Toby님의 지적에 따라 잘못된 번역을 수정하고 몇몇 문장을 손 봤습니다.

2009/4/2 : 문서가 망가져서 일부 다시 번역했습니다.

2010/11/23: 번역을 다듬고 오역을 수정함



10. 경험주의적 접근 

  " 경험을 통해 지속적으로 결정을 내리고, 

    개선을 통해 더 나은 가치를 전달한다." 

  결점 : 큰 그림을 보기 어렵다. 



11. FAT BUGGER 사례 

  1) 15$ 햄버거를 7$를 가지고 와서 주문

  2) 알바생 임의대로 제품을 만들어 판매  -> 사망

    

  1. 의사결정은 고객일 할 수 있도록 정보를 전달한다. 

  2. 고객의 요구에 대한 리스크 및 영향도를 고객이 알 수 있도록 한다.  

  

  3) 10% 실명 위기를 갖고 있는 시력 수술의 경우에도 실패율을 사전에 공지 받았던 환자들의 경우에는

      실패한다 해도 의사에 대한 원망이 상대적으로 크지 않을 것임.



12. Agile과 Scrum은 개발자들의 높은 Craftsman Ship을 요구한다. 


13. Scrum 실습 :  공돌리기 

   1) Rule

     ㄱ. 공은 모든 구성원의 손에 닿아야 함.

     ㄴ. 바로 옆 구성원의 구성원에게는 전달할 수 없음

     ㄷ. 공을 전달할 때는 반드시 누구에게도 닿지 않는 시간이 있어야 함.

   2) 목표 : 정해진 시간(2분)내에 최대한 많은 갯수를 진행함

   3) 총 5회, 매 횟수마다 1분의 협의시간을 통해 개선점을 찾는다. 

   4) 다름 표에 기록


 횟수

추정

실행 

개선사항 

 1


 

 

 2

 

 

 

 3

 

 

 

 4

 

 

 

 5

 

 

 


 <게임과 SCRUM 비교>

구분

게임

SCRUM 

 계획

 추정하기

 sprint planning

 실행

 2분게임 

 sprint

 학습

 1분 협의

 Review & Retrospect

 DSM (Daily Scrum Meeting)

  




14. What is SCRUM !















Posted by 꿈을펼쳐라
,

https://github.com/wooridle/DeepRL_tutorial/blob/master/install_guide_window.md   

Posted by 꿈을펼쳐라
,

Lec 12  Recurrent Neural Network


1. Concept of RNN

   1) Basic Concept

       


        - 현재의 상태값을 계산하는데, 이전의 상태값이 사용됨           

        - 단, 모든 타입 스텝에 대해ㅏ여 동일 함수, 동일 파라미터가 적용됨 

   2) Vanilla RNN 

       


   3) Character-level Language Model 

      - output layer값으로 solftMax를 구하여 정확도를 구하고, 정확도의 평균을 

        Cost 함수로 하여 최소화하는 학습을 진행할 수 있음 


     

 2. RNN applications

  1) application field  

      • Language Modeling 
      • Speech Recognition
      • Machine Translation
      • Conversation Modeling / Question Answering (Chat Bot) 
      • Image / Video Captioning 
      • Image / Music / Dance Generation

        참고 : https://github.com/TensorFlowKR/awesome_tensorflow_implementations


  2) application type 

    - one to one : Vanilla Neural Networks

    - one to many : Image Captioning  

    - many to one : Sentiment Classification 

    - many to many : Machine Translation 

    - many to many : Video Classification on frame level

 

  3) multi-Layer RNN


  4) RNN Training Model 

     - Long Short Term Memory (LSTM) 

     - GRU by Cho. et al. 2014




Lab 12  RNN in TF

1. Concept of RNN in TF 

   1) Cell : 상황에 따라서 결정 (hiden_size는 자유롭게 설정 가능)

   2) 결과 : outputs과, states 두 개가 나오지만, states는 거의 사용하지 않음



2. Input / Output RNN in TF  

   1) One Node: 4 input in 2 hidden_size 

  2) Unfolding to n sequence



  3) Batching Input / Output



3. ....


Posted by 꿈을펼쳐라
,

Lec 11  ConvNet의 Conv 레이어 만들기

1.  Concept of Convolution


 고양이 뇌 실험을 통해 스크린의 변화를 인지하는 데 사용하는 뇌의 기능은 뇌 전체가 아닌 일부 뇌만을 사용함.

 신경망을 사용할때 전체를 다 파악하는 것이 아닌 부분을 판단하는 방식을 적요하는 방법 




2.  Size of filter



3.  Convolution Layers

4. Pooling Layer

 

convolution Layer와 Pooling Layer와의 차이는 Convolution Layer의 weight는 학습을 통해서 결정되지만 Pooling Layer는 정해진 방식에 따라 적용됨.  ( 학습하는 것이 아닌, 대표값 정하는 방식으로)



5. Case Study


LeCun et. al

2012년 ImageNet 경진 대회 우승   

현재는 Normalization Layer는 사용하지 않음


2014년 ImageNet 경진 대회 우승


2015년 다수의 경진 대회 우승


Revolution of Depth

  - fast forward 기법 적용 :  계산값을 2-3 단계 이후 결과값이 Jump하여 적용 



2016, 2017  이미지넷 우승은?


2016

2.99%의 Trimps-Soushen 팀. (The Third Research Institute of the Ministry of Public Security, 중국 공안부 산하 연구팀). ResNet, Inception, Inception-Resnet를 혼합하여 적용 


2017

사물 종류별 검출 성능 :  남경정보과학기술대(NUIST, 중국 ) 

평균 검출 정확도 : 남경정보과학기술대(NUIST, 중국) , 0.61  




2017년 경진대회를 끝으로 이미지넷 경진 대회는 더 진행하지 않는다고 함.




Lab 11  CNN 

1. CNN Process ( 3 step)


2. CNN with Tensorflow

  1) conv2d 

  2) conv2


  3) MNIST Data Load

  4) apply Conv Layer


  5) apply Max Pooling



이후 MNIST 데이터에 대한 convolution layer 적용은 

https://docs.google.com/presentation/d/1h90rpyWiVlwkuCtMgTLfAVKIiqJrFunnKR7dqPNtI6I/edit#slide=id.g1dc2d142ea_0_399 

에서 확인



Posted by 꿈을펼쳐라
,

Lab 10  NN, ReLu, Xavier, Dropout, and Adam

1.  softmax for MNIST

# define cost/loss & optimizer
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(
    logits=hypothesis, labels=Y))
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)

# initialize
sess = tf.Session()
sess.run(tf.global_variables_initializer())

 

Epoch: 0014 cost = 0.419000337

Epoch: 0015 cost = 0.406490815

Learning Finished!

Accuracy: 0.9035

 

 

 

2.  NN for MNIST with ReLU

 

여러개의 계산 단계를 거침

 

# input place holders

X = tf.placeholder(tf.float32, [None, 784])

Y = tf.placeholder(tf.float32, [None, 10])


# weights & bias for nn layers

W1 = tf.Variable(tf.random_normal([784, 256]))

b1 = tf.Variable(tf.random_normal([256]))

L1 = tf.nn.relu(tf.matmul(X, W1) + b1)


W2 = tf.Variable(tf.random_normal([256, 256]))

b2 = tf.Variable(tf.random_normal([256]))

L2 = tf.nn.relu(tf.matmul(L1, W2) + b2)


W3 = tf.Variable(tf.random_normal([256, 10]))

b3 = tf.Variable(tf.random_normal([10]))

hypothesis = tf.matmul(L2, W3) + b3


# define cost/loss & optimizer

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(

  logits=hypothesis, labels=Y))

optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)

 

Epoch: 0014 cost = 0.624131458

Epoch: 0015 cost = 0.454633765

Learning Finished!

Accuracy: 0.9455

 

 

 

3.  Xavier, Adam for MNIST

 

초기값이 초기부터 낮음 

 

# input place holders

X = tf.placeholder(tf.float32, [None, 784])

Y = tf.placeholder(tf.float32, [None, 10])


# weights & bias for nn layers

# http://stackoverflow.com/questions/33640581

W1 = tf.get_variable("W1", shape=[784, 256],

                   initializer=tf.contrib.layers.xavier_initializer())

b1 = tf.Variable(tf.random_normal([256]))

L1 = tf.nn.relu(tf.matmul(X, W1) + b1)


W2 = tf.get_variable("W2", shape=[256, 256],

                   initializer=tf.contrib.layers.xavier_initializer())

b2 = tf.Variable(tf.random_normal([256]))

L2 = tf.nn.relu(tf.matmul(L1, W2) + b2)


W3 = tf.get_variable("W3", shape=[256, 10],

                   initializer=tf.contrib.layers.xavier_initializer())

b3 = tf.Variable(tf.random_normal([10]))

hypothesis = tf.matmul(L2, W3) + b3


# define cost/loss & optimizer

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(

  logits=hypothesis, labels=Y))

optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)

 

 

 

Epoch: 0001 cost = 0.301498963

Epoch: 0002 cost = 0.107252513

Epoch: 0003 cost = 0.064888892

....

Epoch: 0014 cost = 0.002714260

Epoch: 0015 cost = 0.004707661

Learning Finished!

Accuracy: 0.9783

Epoch: 0001 cost = 141.207671860

Epoch: 0002 cost = 38.788445864

Epoch: 0003 cost = 23.977515479

 

 


 

4.  Deep NN for MNIST

단순한 Deep 만으로는 효과가 나지 않고 Dropout 적용를 통해서 효과 확인

# dropout (keep_prob) rate  0.7 on training, but should be 1 for testing

keep_prob = tf.placeholder(tf.float32)


W1 = tf.get_variable("W1", shape=[784, 512])

b1 = tf.Variable(tf.random_normal([512]))

L1 = tf.nn.relu(tf.matmul(X, W1) + b1)

L1 = tf.nn.dropout(L1, keep_prob=keep_prob)


W2 = tf.get_variable("W2", shape=[512, 512])

b2 = tf.Variable(tf.random_normal([512]))

L2 = tf.nn.relu(tf.matmul(L1, W2) + b2)

L2 = tf.nn.dropout(L2, keep_prob=keep_prob)

# train my model

for epoch in range(training_epochs):

   ...

  for i in range(total_batch):

      batch_xs, batch_ys = mnist.train.next_batch(batch_size)

      feed_dict = {X: batch_xs, Y: batch_ys, keep_prob: 0.7}

      c, _ = sess.run([cost, optimizer], feed_dict=feed_dict)

      avg_cost += c / total_batch


# Test model and check accuracy

correct_prediction = tf.equal(tf.argmax(hypothesis, 1), tf.argmax(Y, 1))

accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

print('Accuracy:', sess.run(accuracy, feed_dict={

    X: mnist.test.images, Y: mnist.test.labels, keep_prob: 1}))

 

Epoch: 0014 cost = 0.041290121

Epoch: 0015 cost = 0.043621063

Learning Finished!

Accuracy: 0.9804!!

 

 

5.  Optimizer : Adam 추천 

   

6. Summary

  • Softmax VS Neural Nets for MNIST, 90% and 94.5%

  • Xavier initialization: 97.8%

  • Deep Neural Nets with Dropout: 98%

  • Adam and other optimizers

  • Exercise: Batch Normalization

Posted by 꿈을펼쳐라
,

Lec 10-1  More than Sigmoid : ReLU

1.  Vanish Gradient 


 Depth가 2~3일 경우에는 잘 해결되었던 문제가, Depth 가 깊어질 수록 문제해결이 어려워짐. 

 

 원인중 하나는 sigmoid함수 적용에 있는데, 아주 크거자 작은 값도 무조건 0~1 사이의 값을 보여지다 보니 그 값의 영향력이 작아지고 이로 인해 정확한 계산이 어려워 진다.



2.  Geoffrey Hinton's Summary  


  • Our labeled datasets were thousands of times too small. 
  • Our computers were millions of times too slow. 
  • We initialized the weights in a stupid way. 
  • We used the wrong type of non-linearity.



3.  ReLU 



  in Tensorflow 


  L1 = tf.sigmoid(tf.matmul(X, W1) + b1) 

  L1 = tf.nn.relu(tf.matmul(X, W1) + b1)


적용 예  

  중간 계산 과정은 모두 ReLU를 사용하고, 마지막에는 Sigmoid를 사용한다.




4. Activation Functions 

 

   1) Sigmoid :  0~1 사이

   2) tanh : -1 ~1 사이

   3) ReLU : -무시, +선형 

   4) Leaky ReLu :-일 경우 0.1 가중치 선형, +경우 1 가중치 선형

   5) max out : 선형변환의 최대값 

   6) ELU : - 구간 지수함수 적용  ( 최대 -1)

  

eluELU RELU maxout cifar-10에 대한 이미지 검색결과



Lec 10-2  Weigth 초기화 잘해보자

1.  Geoffrey Hinton's Summary  


  • Our labeled datasets were thousands of times too small. 
  • Our computers were millions of times too slow. 
  • We initialized the weights in a stupid way. 
  • We used the wrong type of non-linearity.



2.  RBM 

  1) Restricted Boatman Machine 

  2) Hinton et al. (2006) "A Fast Learning Algorithm for Deep Belief Nets” 

  3) concept : 1 단계별 forward & backward시 값차이가 가장 적게 발생하는 weight 값을 초기값으로 사용

  4) Deep Belief Network 


3.  Xavier/He initialization 

  1) Xavier initialization: 

     X. Glorot and Y. Bengio, “Understanding the difficulty of training deep feedforward neural networks,” in International conference on artificial intelligence and statistics, 2010

  2) He’s initialization: 

    K. He, X. Zhang, S. Ren, and J. Sun, “Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification,” 2015

  3) Makes sure the weights are ‘just right’, not too small, not too big 

  4) Using number of input (fan_in) and output (fan_out)

  5) application


def xavier_init(n_inputs, n_outputs, uniform=True):

  """Set the parameter initialization using the method described.
  This method is designed to keep the scale of the gradients roughly the same
  in all layers.
  Xavier Glorot and Yoshua Bengio (2010):
           Understanding the difficulty of training deep feedforward neural
           networks. International conference on artificial intelligence and
           statistics.
  Args:
    n_inputs: The number of input nodes into each output.
    n_outputs: The number of output nodes for each input.
    uniform: If true use a uniform distribution, otherwise use a normal.
  Returns:
    An initializer.
  """
  if uniform:
    # 6 was used in the paper.
    init_range = math.sqrt(6.0 / (n_inputs + n_outputs))
    return tf.random_uniform_initializer(-init_range, init_range)
  else:
    # 3 gives us approximately the same limits as above since this repicks
    # values greater than 2 standard deviations from the mean.
    stddev = math.sqrt(3.0 / (n_inputs + n_outputs))
    return tf.truncated_normal_initializer(stddev=stddev)



Lec 10-3  Dropout과 앙상블


1.  Solutions for overfitting

  1) More training data

  2) Reduce the number of features 

  3) Regularization


2.  Regularization

  1) Let's not have too big numbers in the weight 



  2) Dropout 

    - A Simple Way to Prevent Neural Networks from Overfitting [Srivastava et al. 2014]

   

  - randomly set some neurons to zero in the forward pass  



3. Ensenble



Lec 10-4  레고처럼 네트워크 모듈을 마음껏 쌓아 보자



Posted by 꿈을펼쳐라
,

Lec 09-1  Neural Nets(NN) for XOR

1. Forward Propagation 



  


2. NN for Vector 


   


K= tf.sigmoid(tf.matmul(X,W1) + b1)

hypothesis = tf.sigmoid(tf.matmul(K,W2) + b2 )


Lec 09-x  미분 정리하기 

1. Basic derivative 


    


2. Partial derivative : consider other variables as constants



Lec 09-2  딥넷트웍 학습 시키기 (backpropagation)

1. Back propagation 


   1) 1974, 1982 by Paul Werbos, 1986 by Hinton

  

    

    https://devblogs.nvidia.com/parallelforall/inference-next-step-gpu-accelerated-deep-learning/

 

2. Back Propagation (chain rule)

  1) forward (w =-2, x=5, b=3) 

  2) backward : derivative


    

    3) derivative sigmoid

     

       



Lab 09-1 : Neural Net for XOR

1. XOR data set 

x_data = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], dtype=np.float32)

y_data = np.array([[0],    [1],    [1],    [0]], dtype=np.float32)


2. Single Model로는 풀수 없음 


3. Neural Nets for XOR 

W = tf.Variable(tf.random_normal([2, 1]), name='weight')

b = tf.Variable(tf.random_normal([1]), name='bias')


# Hypothesis using sigmoid: tf.div(1., 1. + tf.exp(tf.matmul(X, W)))

hypothesis = tf.sigmoid(tf.matmul(X, W) + b)



W1 = tf.Variable(tf.random_normal([2, 2]), name='weight1')

b1 = tf.Variable(tf.random_normal([2]), name='bias1')

layer1 = tf.sigmoid(tf.matmul(X, W1) + b1)


W2 = tf.Variable(tf.random_normal([2, 1]), name='weight2')

b2 = tf.Variable(tf.random_normal([1]), name='bias2')

hypothesis = tf.sigmoid(tf.matmul(layer1, W2) + b2)


Hypothesis:  [[ 0.01338216]

 [ 0.98166394]

 [ 0.98809403]

 [ 0.01135799]] 

Correct:  [[ 0.]

 [ 1.]

 [ 1.]

 [ 0.]] 

Accuracy:  1.0


4. Wide & Deep 

    1) Wide : 변수의 갯수를 늘리는 것 

    2) Deep : 모델 수를 더 많이 사용하는 것 (



Lab 09-2 : Tensorboard (Neural Net for XOR)

1. 5 steps of using TensorBoard 


1 step : From TF graph, decide which tensors you want to log

w2_hist = tf.summary.histogram("weights2", W2)

cost_summ = tf.summary.scalar("cost", cost)

2 step : Merge all summaries

summary = tf.summary.merge_all()

3 step : Create writer and add graph

# Create summary writer

writer = tf.summary.FileWriter(‘./logs’)

writer.add_graph(sess.graph)

4 step : Run summary merge and add_summary

s, _ = sess.run([summary, optimizer], feed_dict=feed_dict)

writer.add_summary(s, global_step=global_step)

5 step : Launch TensorBoard

tensorboard --logdir=./logs


2. Result of tensorflow





Posted by 꿈을펼쳐라
,

Lec 08-1 딥러닝의 기본 개념: 시작과 XOR 문제

1. Activation Functions


   사람의 신경을 연구하여 유사 구조로 만듦

2. XOR Problem :


   1) 선형적 논리구조로는 풀지 못함. 

   2) Perceptrons (1969 ) by Marvin Minsky, founder of the MIT AI Lab


   3) Backpropagation (1974, 1982 by Paul Werbos,  1986 by Hinton)




3. Convolutional Neural Networks

   1) 고양이 뇌 실험 

    - 뇌가 이미지를 판단할 때 전체를 사용하는 것이 아니라 그림의 형태에 따라 일부의 뉴런만 사용한다. 

    2) 부분만 사용하여 연산한 후 나중에 합치는 방식 : LeCun 



4. Big Problem


  1) Backpropagation just did not work well for normal neural nets with many

  2) Other rising machine learning algorithms: SVM, RandomForest, etc.

  3) 1995 “Comparison of Learning Algorithms For Handwritten Digit Recognition” by LeCun et al. 

     found that this new approach worked better



Lec 08-2 딥러닝의 기본 개념 2: back-propagation 과 2006/2007 '딥'의 출현

1. Breakthrough : in 2006 and 2007 by Hinton and Bengio

  1) Neural networks with many layers really could be trained well,

     if the weights are initialized in a clever way rather than randomly.

  2) Deep machine learning methods are more efficient for difficult problems than shallow methods.

  3) Rebranding to Deep Nets, Deep Learning


2. ImageNet Classification (2012 ) : 26.2% -> 15.3 %  

   1) 2015년 standford 연구생이 코딩으로 개발한 건보다, CNN을 이용해서 개발한 모델이 정확하게 예측함



Lab 08 Tensor Manipulation

1. Array  

  1) Simple Array [1D]

t = np.array([0., 1., 2., 3., 4., 5., 6.])

pp.pprint(t)

print(t.ndim) # rank

print(t.shape) # shape

print(t[0], t[1], t[-1])

print(t[2:5], t[4:-1])

print(t[:2], t[3:])

array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.])

1   -> 김성훈 교수님 예제 잘못되어 있음 

(7,)

0.0 1.0 6.0

[ 2.  3.  4.] [ 4.  5.]

[ 0.  1.] [ 3.  4.  5.  6.]


  2) 2D Array 

t = np.array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.], [10., 11., 12.]])

pp.pprint(t)

print(t.ndim) # rank

print(t.shape) # shape

array([[  1.,   2.,   3.],

       [  4.,   5.,   6.],

       [  7.,   8.,   9.],

       [ 10.,  11.,  12.]])

2

(4, 3)


  3) Shape, Rank, Axis

Shape : 배열의 크기  - 가장 안쪽에서 뒤에서 부터 표시

Rank : 배열의 차원

Axis : 배열 요소의 순서 ( X :0 , Y : 1, Z : 3) 


  4) MatMul Vs multiply 

matrix1 = tf.constant([[3., 3.]])

matrix2 = tf.constant([[2.],[2.]])


tf.matmul(matrix1, matrix2).eval()

(matrix1*matrix2).eval()

[[ 12.]]

[[ 6.  6.]

 [ 6.  6.]]


  5) Watch Out Broadcast


2. Function

  1) Reduce mean 

tf.reduce_mean([1, 2], axis=0).eval()

x = [[1., 2.],

     [3., 4.]]

tf.reduce_mean(x).eval()

tf.reduce_mean(x, axis=0).eval()

tf.reduce_mean(x, axis=1).eval()

tf.reduce_mean(x, axis=-1).eval()

1

2.5

[ 2.  3.]

[ 1.5  3.5]

[ 1.5  3.5]


  2) Reduce sum

x = [[1., 2.],

     [3., 4.]]

tf.reduce_sum(x).eval()

tf.reduce_sum(x, axis=0).eval()

tf.reduce_sum(x, axis=-1).eval()

tf.reduce_mean(tf.reduce_sum(x, axis=-1)).eval()

10.0

[ 4.  6.]

[ 3.  7.]

5.0


  3) Argmax : 가장 큰 값의 위치가 어디냐? 

x = [[0, 1, 2],

     [2, 1, 0]]

tf.argmax(x, axis=0).eval()

tf.argmax(x, axis=1).eval()

tf.argmax(x, axis=-1).eval()

[1 0 0]

[2 0]

[2 0]


  4) Reshape, squeeze, expand

t = np.array([[[0, 1, 2], 

               [3, 4, 5]],              

              [[6, 7, 8], 

               [9, 10, 11]]])

t.shape

tf.reshape(t, shape=[-1, 3]).eval()

tf.reshape(t, shape=[-1, 1, 3]).eval()

tf.squeeze([[0], [1], [2]]).eval()

tf.expand_dims([0, 1, 2], 1).eval()

(2, 2, 3)

[[ 0  1  2]

 [ 3  4  5]

 [ 6  7  8]

 [ 9 10 11]]

[[[ 0  1  2]]


 [[ 3  4  5]]


 [[ 6  7  8]]


 [[ 9 10 11]]]

[0 1 2]

[[0]

 [1]

 [2]]



  5) Onehot : 

tf.one_hot([[0], [1], [2], [0]], depth=3).eval()

t = tf.one_hot([[0], [1], [2], [0]], depth=3)

tf.reshape(t, shape=[-1, 3]).eval()

[[[ 1.  0.  0.]]

 [[ 0.  1.  0.]]

 [[ 0.  0.  1.]]

 [[ 1.  0.  0.]]]


[[ 1.  0.  0.]

 [ 0.  1.  0.]

 [ 0.  0.  1.]

 [ 1.  0.  0.]]


  6) Cast / Stack /ones-zeros / zip

tf.cast([1.8, 2.2, 3.3, 4.9], tf.int32).eval()

tf.cast([True, False, 1 == 1, 0 == 1], tf.int32).eval()

#Stack

x = [1, 4]

y = [2, 5]

z = [3, 6]

# Pack along first dim.

tf.stack([x, y, z]).eval()

tf.stack([x, y, z], axis=1).eval()

x = [[0, 1, 2],

     [2, 1, 0]]

tf.ones_like(x).eval()

tf.zeros_like(x).eval()

#Zip

for x, y in zip([1, 2, 3], [4, 5, 6]):

    print(x, y)

for x, y, z in zip([1, 2, 3], [4, 5, 6], [7, 8, 9]):

          print(x, y, z)[1 0 0]

===cast

[1 2 3 4]

[1 0 1 0]

===stack

[[1 4]

 [2 5]

 [3 6]]

[[1 2 3]

 [4 5 6]]

===ones, zeros

[[1 1 1]

 [1 1 1]]

[[0 0 0]

 [0 0 0]]

===zip

1 4

2 5

3 6

1 4 7

2 5 8

3 6 9

Posted by 꿈을펼쳐라
,

Lec 07-1 Learning Rate, Overfitting and Regularization

1. Determining Learning Rate

    1) Try Several learning Rates ( start with 0.01 )

    2) Observe the cost function 

    3) Check it goes down in a reasonable rate 

      - 너무 크면 divergence ,  너무 작은면 늦게 수렴


2. Data(X) Preprocessing for gradient descent 

   1) RAW data가 편중되어 있을 경우, 특정 변수의 민감도가 높거나 낮아질 수 있음. 

   2) Normalization 


    3) Standardization 

          

           X_std[:,0] = (X[:0] - X[:,0].mean()) / X[:,0].std()   


2. Regularization  

   1) OverFitting 

      - Our model is very good with training data set (with memorization)

      - Not good at test dataset or in real use

    2) Solutions for overfitting 

       - More Training data 

       - Reduce the number of features 

       - Regularization 


    3) Regularization 

       - Let's not have too big numbers in the weight      

         

        ( Loss함수에 Weight크기를 포함하도록 함으로써 해당 값도 최소화하는 경우를 찾고자 함)  

       - with Tensorflow 

          l2reg = 0.001 * tf.reduce_sum(tf.square(W)) 


     


Lec 07-2: Training/Testing Data Set


1. Data set 


2. Online Learning 

    1) 데이터 셋을 여러 단위로 분리해서 예측 진행

    2) 이전 단계에서 예측돼었던 내용이 새로운 데이터 셋 예측에서도 동일한 영향을 주여야 함 



3. M NIST Data set





Lab 07-1: training/test dataset, learning rate, normalization


1. Test Dataset  & Learning Rate  

  0) Test Data

   # Evaluation our model using this test dataset

   x_test = [[2, 1, 1],          

            [3, 1, 2],       

            [3, 3, 4]]

   y_test = [[0, 0, 1],

             [0, 0, 1],

             [0, 0, 1]]


   1) optimizer = tf.train.GradientDescentOptimizer(learning_rate=1e-10).minimize(cost)

TOOL Small : Local Min. No Progress


200 5.73203 [[ 0.80269569  0.67861289 -1.21728313]

 [-0.3051686  -0.3032113   1.50825703]

 [ 0.75722361 -0.7008909  -2.10820389]]

Prediction: [0 0 0]

Accuracy:  0.0

   2) optimizer = tf.train.GradientDescentOptimizer(learning_rate=1.5).minimize(cost)

TOOL Large : Divergen


200 nan [[ nan  nan  nan]

 [ nan  nan  nan]

 [ nan  nan  nan]]

Prediction: [0 0 0]

Accuracy:  0.0

  3) optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1).minimize(cost)

Proper Initial : 


200 0.670909 [[-1.15377057  0.2814692   1.13632655]

 [ 0.37484601  0.18958248  0.33544892]

 [-0.35609847 -0.43973017 -1.256042  ]]

Prediction: [2 2 2]

Accuracy:  1.0


2. Normalized input

  1) Large Value Raw Data 

     y = np.array([[828.659973, 833.450012, 908100, 828.349976, 831.659973],

                   [823.02002, 828.070007, 1828100, 821.655029, 828.070007],

                   [819.929993, 824.400024, 1438100, 818.97998, 824.159973],

                   [816, 820.958984, 1008100, 815.48999, 819.23999],

                   [819.359985, 823, 1188100, 818.469971, 818.97998],

               [819, 823, 1198100, 816, 820.450012],

                   [811.700012, 815.25, 1098100, 809.780029, 813.669983],

                   [809.51001, 816.659973, 1398100, 804.539978, 809.559998]])

100 Cost:  nan 

Prediction:

 [[ nan]

 [ nan]

 [ nan]

 [ nan]

 [ nan]

 [ nan]

 [ nan]

 [ nan]]


Process finished with exit code 0


  2) Normalized input 

def MinMaxScaler(data):

    numerator = data - np.min(data, 0)

    denominator = np.max(data, 0) - np.min(data, 0)

    # noise term prevents the zero division

    return numerator / (denominator + 1e-7)


...


xy = MinMaxScaler(xy)


100 Cost:  0.0136869 

Prediction:

 [[ 1.12295258]

 [ 0.63500863]

 [ 0.53340685]

 [ 0.4315863 ]

 [ 0.53191048]

 [ 0.55868214]

 [ 0.15761785]

 [ 0.14425412]]


Process finished with exit code 0



Lab 07-2: Meet MNIST Dataset


1. MNIST  Image

  1) 28 * 28 * 1 Image (Binary Bitmap



# MNIST data image of shape 28 * 28 = 784

X = tf.placeholder(tf.float32, [None, 784])

# 0 - 9 digits recognition = 10 classes

Y = tf.placeholder(tf.float32, [None, nb_classes])



2. Reading Data and set variables


from tensorflow.examples.tutorials.mnist import input_data

# Check out https://www.tensorflow.org/get_started/mnist/beginners for

# more information about the mnist dataset

mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)


nb_classes = 10


# MNIST data image of shape 28 * 28 = 784

X = tf.placeholder(tf.float32, [None, 784])

# 0 - 9 digits recognition = 10 classes

Y = tf.placeholder(tf.float32, [None, nb_classes])


W = tf.Variable(tf.random_normal([784, nb_classes]))

b = tf.Variable(tf.random_normal([nb_classes]))


...
batch_xs, batch_ys = mnist.train.next_batch(100)
...
print("Accuracy: ", accuracy.eval(session=sess, feed_dict={X: mnist.test.images, Y: mnist.test.labels}))


3. SoftMax

# Hypothesis (using softmax)

hypothesis = tf.nn.softmax(tf.matmul(X, W) + b)


cost = tf.reduce_mean(-tf.reduce_sum(Y * tf.log(hypothesis), axis=1))

optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1).minimize(cost)


# Test model

is_correct = tf.equal(tf.arg_max(hypothesis, 1), tf.arg_max(Y, 1))

# Calculate accuracy

accuracy = tf.reduce_mean(tf.cast(is_correct, tf.float32))


4. epoch / Batch


1) 데이터가 많을 경우, 모든 데이터를 올리려면 Memory가 많이 필요하므로, Batch로 분할하여 적용

2) epoch [에폭] : 전체 데이터를 한번 모두 훈련하는 과정

3) iteration per epoch = [전체데이터 수] / [batch_size]


# parameters

training_epochs = 15

batch_size = 100


with tf.Session() as sess:

   # Initialize TensorFlow variables

   sess.run(tf.global_variables_initializer())

   # Training cycle

   for epoch in range(training_epochs):

       avg_cost = 0

       total_batch = int(mnist.train.num_examples / batch_size)


       for i in range(total_batch):

           batch_xs, batch_ys = mnist.train.next_batch(batch_size)

           c, _ = sess.run([cost, optimizer], feed_dict={X: batch_xs, Y: batch_ys})

           avg_cost += c / total_batch


       print('Epoch:', '%04d' % (epoch + 1), 'cost =', '{:.9f}'.format(avg_cost))



5. Result


1) 0.8951 정확도


Epoch: 0007 cost = 0.591160339 Epoch: 0008 cost = 0.563868978 Epoch: 0009 cost = 0.541745167 Epoch: 0010 cost = 0.522673571 Epoch: 0011 cost = 0.506782322 Epoch: 0012 cost = 0.492447640 Epoch: 0013 cost = 0.479955830 Epoch: 0014 cost = 0.468893666 Epoch: 0015 cost = 0.458703479 Learning finished Accuracy: 0.8951 Label: [3] Prediction: [5] 


3을 5로 인식한 결과

7을 2로 인식하였다.   아직 89 % 정확도 이니까...


  2) Learning Rate, Epoch 회수 조정으로 정확도를 더 높일 수 있다.  

     Learning Rate = 0.4 ,   Epoch = 100시     92.25%

Epoch: 0098 cost = 0.243552753

Epoch: 0099 cost = 0.243438786

Epoch: 0100 cost = 0.243145558

Learning finished

Accuracy:  0.9225

Label:  [5]

Prediction:  [5]


Posted by 꿈을펼쳐라
,