이미지 인식을 하기 위해서 아래 그림 처럼 처리하면됩니다.

(아래 그림에서는 빠졌는데 Dropout를 처리해주면 더 좋은 결과를 얻을수 있습니다.)






[사례]

CNN Demo :  https://cs.stanford.edu/people/karpathy/convnetjs/demo/cifar10.html

CT 영상에서 폐결절 환자의 폐암 진단 알고리즘 : https://www.slideshare.net/GYLee3/ss-72966495


[학습 자료 ] Convolutional Neural Networks

홍콩 과기대 김성훈 교수 (https://hunkim.github.io/ml/)


Ex)간단히 명령어 해석

conv2d = tf.nn.conv2d(image, weight, strides=[1,1,1,1], padding='SAME')

*image.shape   -- (1,7,6,3) : 1(이미지갯수 만일"-1"이면 갯수 정하지 않음) 7x6크기x 3(RGB)

*weight.shape  -- (5,4,3,2) : 5x4크기x 3(RGB) x2(Filter 갯수)

*strides[1,1,1,1] --  1(?),,1(x축 이동),1(y축 이동), 1(?)

*padding ='SAME' -- CNN후 대상 이미지와 같은 사이즈 결과물 만들기


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

CNN MNIST : 99% https://github.com/hunkim/DeepLearningZeroToAll/blob/master/lab-11-2-mnist_deep_cnn.py

[해석]

X = tf.placeholder(tf.float32, [None, 784])    #  None(이미지 갯수 정의하지 않음), 784(784 pixel/1 image)

X_img = tf.reshape(X, [-1, 28, 28, 1])           # -1(이미지 갯수 정의하지 않음), 28x28(size), 1(black/white)

Y = tf.placeholder(tf.float32, [None, 10])      # None(이미지 갯수 정의하지 않음), 0~9까지의 숫자


############## Convolutional layer two layer로 구성

#Layer 1 Image(?,28,28,1)

W1 = tf.Variable(tf.random_normal([3, 3, 1, 32], stddev=0.01)) #3x3(size) , 1(Black&white) , 32 of filters


L1 = tf.nn.conv2d(X_img, W1, strides=[1, 1, 1, 1], padding='SAME') #strides 1(?),1(x축),1(y축),1(?), padding=SAME CNN후 대상과 같은 크기 만들기

L1 = tf.nn.relu(L1)

L1 = tf.nn.max_pool(L1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') #ksize(kernerl size) 1(?)2x2(szie),1(?), strides1(?),2(x축),2(y축),1(?)

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


#Layer 2 Image(?,14,14,32)

W2 = tf.Variable(tf.random_normal([3, 3, 32, 64], stddev=0.01))  #3x3, 32(앞 layer의 filter 수), 64(이번 layer 정한 filter수)


L2 = tf.nn.conv2d(L1, W2, strides=[1, 1, 1, 1], padding='SAME')

L2 = tf.nn.relu(L2)

L2 = tf.nn.max_pool(L2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')

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

#Max Pool 후 image(?,7,7,64)


L2_flat = tf.reshape(L2, [-1, 7 * 7 * 64])     #one line으로 펼치기 위함. -1(N개의 값), 1 image 당 7*7*64(=3136)개의 값


############## Fully connected two layer로 구성

# First layer 출력을 625로 설정

W3 = tf.get_variable("W3", shape=[7 * 7 * 64, 625], initializer=tf.contrib.layers.xavier_initializer()) #7*7*64갯수, 625출력

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

L3 = tf.nn.relu(tf.matmul(L2_flat, W3) + b3)

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



# Second Layer(Final)  625 inputs -> 10 outputs(0~9까지의 숫자)

W4 = tf.get_variable("W4", shape=[625, 10], initializer=tf.contrib.layers.xavier_initializer())

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

logits = tf.matmul(L4, W5) + b5


# define cost/loss & optimizer

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=Y))

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


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

위 CNN 예제를 Class로 변경 예제 : https://github.com/hunkim/DeepLearningZeroToAll/blob/master/lab-11-3-mnist_cnn_class.py


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


클래스 만들때 참조. tf.layers 예제 : https://github.com/hunkim/DeepLearningZeroToAll/blob/master/lab-11-4-mnist_cnn_layers.py

# Convolutional Layer #1

conv1 = tf.layers.conv2d(inputs=X_img,filters=32,kernel_size=[3,3],padding="SAME",activation=tf.nn.relu)

pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=[2, 2], padding="SAME", strides=2)

dropout1 = tf.layers.dropout(inputs=pool1,rate=0.7, training=self.training)


# Convolutional Layer #2

conv2 = tf.layers.conv2d(inputs=dropout1,filters=64,kernel_size=[3,3],padding="SAME",activation=tf.nn.relu)

flat = tf.reshape(dropout3, [-1, 128 * 4 * 4])

dense4 = tf.layers.dense(inputs=flat, units=625, activation=tf.nn.relu)

dropout4 = tf.layers.dropout(inputs=dense4, rate=0.5, training=self.training)

...

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


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


또 다른 실습 코드 : 포스팅 하단에 보면 존재. 50번 반복에 정확도 95.5%

https://medium.com/@jongdae.lim/%EA%B8%B0%EA%B3%84-%ED%95%99%EC%8A%B5-machine-learning-%EC%9D%80-%EC%A6%90%EA%B2%81%EB%8B%A4-part-3-928a841a3aa


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


다른 학습 자료 : 조대협씨 연예인 얼굴 인식 모델을 만들어 보자. http://bcho.tistory.com/1178

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



[실습] 새 분류기 만들기 

무료 CIFAR10 Data(6,000장 새 사진& 52,000장 새가 아닌 사진) : https://www.cs.toronto.edu/~kriz/cifar.html  

Caltech-UCSD Birds-200-2011 Data (12,000장 새 사진) : http://www.vision.caltech.edu/visipedia/CUB-200-2011.html



Openai의 Gym 설치를 위한 Doc는 아래와 같습니다.

https://gym.openai.com/docs/


설치 명령어가 아래와 같은데 "git" 설치 안되어 있으면 동작을 안합니다.

git clone https://github.com/openai/gym

cd gym

pip install -e . # minimal install


먼저 git를 설치한수에 위 명령을 실행하면됩니다.

https://git-scm.com/download/win


설치후 git의 CMD를 실행 하고 위 명령어를 입력하면 아래 그림처럼 설치가 완료됩니다.


Tensorflow가 오류없이 설치되었을때 이후 무료 편집 프로그램에서 동작하게끔 환경 설정하는것입니다.


Python 무료 편집 프로그램(PyCharm for community)는 아래에서 다운 후 설치하세요

https://www.jetbrains.com/pycharm/download/#section=windows


설치 후 이젠 연결을 해줘야합니다.

신규 프로젝트르 만들때 , 빨간부분을 누르면 Creat Conda Env가 있습니다.


디폴트 값이 잘들어왔을거라 믿고, Name과 혹은 location은 원하시는데로 변경하시면됩니다.

OK를 누르면 동작하는데 좀 시간 걸리고, 이후  interpreter 내용이 변경되었음을 확인하면됩니다.



이후 

왼쪽에 하이라키 구조 untitled1에서 오른쪽 마우스 클릭 New> Python File 하시면  이름 입력 후 python작성이 가능합니다.


그리고 이제 Tools>Python Console...를 누르면 하단에 창이 올라옵니다. ">>>" 이런 커멘트 입력 대기가 표시되는데

다음과 같이 입력하시면됩니다.

">>> import pip"

">>> pip.main(['install','tensorflow-gpu'])      // GPU버전이라서 gpu 옵션을 넣었습니다. 아니며 "-gpu"를 빼시면됩니다.


위 그림처럼 오류 없이 처리됩니다.


동작 확인을 위해 아래 코드를 입력 후 실행해보시고, 출력값 확인하시면 되겠습니다.


import tensorflow as tf

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

sess=tf.Session()

print(sess.run(hello))


a=tf.constant(10)

b=tf.constant(32)

print(sess.run(a+b))





참고: Jupyter편집툴(?)로 Tensorflow coding하기 

https://steemit.com/it/@sukjunko/38ndhz-sj




TensorFlow 설치 때문에 몇일간 시간 낭비하다보니, 만들게 되었습니다. 

제가 다 알지는 못하지만, 도움이 되면 좋겠습니다.


참조 : TensorFlow 설치 웹 사이트

https://www.tensorflow.org/install/install_windows


설치 순서를 아래와 같이 하면됩니다.


1. Visual studio 설치하기

community 2017를 설치하면됨.(설치시 C++컴파일러를 선택해주세요) 

https://www.visualstudio.com/



2. CUDA 8.0 Toolkit 설치하기(구형 버전이지만 현재까지는 8.0을 설치해야함)

https://developer.nvidia.com/cuda-80-ga2-download-archive




3. Path 설정 확인 ( Start 버튼 옆 search에 "Enviroment" 입력 하면 Edit System Eviroment xxx가 표시됨. 선택)

CUDA\x\bin 과, CUDA\x\libnvvp 패스 확인




4.  NVIDIA 드라이버 최신 확인 또는 설치

(Tip : GPU 정보 보기 //  Search에 " dxdiag" 입력 실행. Display tap보면됨.)

http://www.nvidia.com/Download/index.aspx


5. cuDNN v6.0 설치 ( 설치를 위해 개발자 등록을 해야함.)

https://developer.nvidia.com/cudnn

압축을 풀고 C:에 복사. "cudnn64_6dll" 파일이 있는 위치(cuda\bin)를 Enviroment에 등록함. 

3번 순서 참조


6. Anaconda 설치 ( Tensorflow에서 python 3.5 설치를 요구하기에 현재까진 최신버전이 아님. )

구 버전이 있는곳  https://repo.continuum.io/archive/

이중 https://repo.continuum.io/archive/Anaconda3-4.2.0-Windows-x86_64.exe

이를 설치하시면됨.


7. "윈도우 키 + R"  입력후 cmd 실행 // (콘다환경 설정)


"C:> conda create -n tensorflow python=3.5" 입력


"C:> activate tensorflow" 입력


"(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu" 입력 // GPU 버전임


에러 없으면.설치 완료됨. 


이어서 [검증하기]

설치완료 후 "python " 입력



>>> import tensorflow as tf

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

>>> sess = tf.Session()

>>> print(sess.run(hello))

아래와 같이 인쇄되면 검증 성공.

Hello, TensorFlow!

끝.



참고 : 

*python 기초 강좌(책)

 http://byteofpython-korean.sourceforge.net/byte_of_python.pdf

http://www.flowdas.com/thinkpython/


*python 무료 편집 프로그램(PyCharm for community)

https://www.jetbrains.com/pycharm/download/#section=windows

It will be posted soon.

'Strategic Thinking' 카테고리의 다른 글

Core ML in Apple WWDC2017  (0) 2017.10.24
iPhone X's Strategy  (0) 2017.10.13
Tesla's Music Strategy  (0) 2017.10.13
One among the strategies of iPhone 7  (0) 2017.10.12

The following image which I have summarized is Core ML announced in Apple WWDC 2017(June 26 2017).

It seems that it contains many APIs that can be used easy in applications.

In the actual demo, it showed how easy to apply a by few lines of code.


Again,

By providing ML learning by Apple, app developers can easily apply ML without knowing it.

Perspective Apple, it can be applied to a lot of apps in the AppStore and maintain the same quality.

It is enough to reinforce the ecosystem. 

Apple's services revenue is gleaned from iTunes, iCloud, Apple Music, Apple Pay, Apple Care and the various App Stores.

Apple's last four quarters of service revenue total $27.804 billion. That figure puts it in 97th place ahead of Facebook's entire business at $27.64 billion.   - August 1. 2017

Source : http://appleinsider.com/articles/17/08/01/apples-services-business-alone-now-the-size-of-a-fortune-100-company-beats-out-facebook


But I want to see if Apple pursue other monetary advantages like collecting data.



One more image. 

This image show Core ML's compatible and extensible.

'Strategic Thinking' 카테고리의 다른 글

Google Cloud Next '17 - Mar 9, 2017  (0) 2017.11.03
iPhone X's Strategy  (0) 2017.10.13
Tesla's Music Strategy  (0) 2017.10.13
One among the strategies of iPhone 7  (0) 2017.10.12

This content was created when I saw iPhone X keynote .



First, let's look at the market share of mobile messenger Apps & iMessage situation.


iMessage Market Share : World-wide monthly active users for popular messaging apps in Jan 2016

Source : https://www.wsj.com/articles/the-future-of-texting-e-commerce-1451951064


Six months in, iMessage App Store growth slows as developers lose interest in Mar 2017

https://techcrunch.com/2017/03/16/six-months-in-imessage-app-store-growth-slows-as-developers-lose-interest/



Do you think that adding Animoji will very help increase the active users of Messaging apps? By Animoji

Maybe ? But it is hard to agree. I think there are other important strategies.

For reference, Increasing Facebook active user from 2016 to 2017,   Chatbot announced in April 2016.

2015 Source : http://1.bp.blogspot.com/-s0xcQ0nDmrA/VagsLYbHCFI/AAAAAAABiNw/3eeG7Sr8a6A/s1600/statistic_id258749_most-popular-global-mobile-messenger-apps-2015.png

2017 Source : https://www.statista.com/statistics/258749/most-popular-global-mobile-messenger-apps/ 


Again,

Apple celebrates its 10th anniversary, the Animoji is one of main key features of the phone for the next 10 years.

Why?


Let's see the movie.

IBM Watson presents Soul Machines : https://www.youtube.com/watch?v=khr-eWGhTSI&feature=youtu.be


Question.

What kind of the assistant do you imagine beyond Chat Bot > Voice Assistant? 

Yes, we can guess answer. 


What is needed to realize this?


Let's see one more movie.

Soul Machines on News Hub : https://youtu.be/0-BSrFQv2ls

To realized it, you know what needs from the viewpoint of Machine learning > Supervised learning.

Yes. Data!!


Again,

Why is Animoji important to Apple Manufacturing company?




'Strategic Thinking' 카테고리의 다른 글

Google Cloud Next '17 - Mar 9, 2017  (0) 2017.11.03
Core ML in Apple WWDC2017  (0) 2017.10.24
Tesla's Music Strategy  (0) 2017.10.13
One among the strategies of iPhone 7  (0) 2017.10.12

I was interested in this topic when Elon Musk announced about Music streaming service.

Although this content was created on July 2017, I would post it soon. 



'Strategic Thinking' 카테고리의 다른 글

Google Cloud Next '17 - Mar 9, 2017  (0) 2017.11.03
Core ML in Apple WWDC2017  (0) 2017.10.24
iPhone X's Strategy  (0) 2017.10.13
One among the strategies of iPhone 7  (0) 2017.10.12

This content was created last year when I saw an iPhone 7 keynote and shared it within the company. 

But I updated it to add article about Apple's service revenue in 2017.


Overview

People said they were disappointed that Apple did't have new technology(Wow or Innovation ).

But there is something interesting.


iOS10 : Siri, Home Kit, Message, Live phone, RAW

1.Design - Glass, black
2.Home button
Home, Multitasking, Siri, Accessibility, Touch ID, Reachability, Apple Pay
à Taptic Engine for Quick Action (Messages, Notifications, Ringtones)
3.Water and dust resistant
4.12MP Camera stabilization,f1.8, 6 Lens, Quad-LED, Updated ISP, Front Camera 7MP
    iPhone7+ : Twin 12MP Camera(Wide&Telephoto)- Zoom 2x, Sneak Peek
5.Retina HD display – Cinema standard, Color management, 3D Touch
6.Stereo Speaker
7.EarPods – adapt –
8.AirPods(Dual accelerometer &optical Sensor & Microphone) – Siri, Phone call, 5H
9.Apply Pay – Japan (Watch)

10.Performance - A10 Fusion 


Today, the several new technologies announced were related for camera functions.


Why is camera function important?


Why is camera function important? 

I think Apple's strategy has something to do with us.


iPhone 7 is pleased to disrupt the mass camera market.

But this level of strategy is a normal strategy the manufacturer has.

You know, competition by better function can be good weapon. 

But this is not all the benefits they want to achieve.


The iPhone, which does not support micro SD, provide more and more high resolution camera, and gradually it will be able to guide users to use storage called iCloud.

The technology like high-resolution cameras is a good material to strengthen service Biz like iCloud.


Apple's benefits by the iPhone 7 launch

-Sales revenue & increasing Market Share (Mass camera market penetration) 

-Service Biz Revenue through the sold products

-Lock-in effect


The most important of these is Service Biz revenue.


Apple's Service Biz (App store, iCloud, iTunes and Apple Pay) Revenue in 2Q 2017

...

Apple's Revenue for the past four quarters totaled roughly $26.5 billion, which trounces Netflix's total revenue over the same period of about $9.5 billion. It's also catching up to Facebook, which generated $27.6 billion in revenue in the past four quarters. 

..

Apple doesn't break out revenue for each of Services' individual units (the App Store, iCloud, iTunes and Apple Pay), but the App Store remains its biggest cash cow. Second to that would be iCloud Storage, which Cook said experienced double-digit revenue growth during the second quarter.

..

Source : https://www.thestreet.com/story/14117382/1/why-sales-from-apple-s-services-unit-already-exceeds-netflix-s-total-revenue.html

'Strategic Thinking' 카테고리의 다른 글

Google Cloud Next '17 - Mar 9, 2017  (0) 2017.11.03
Core ML in Apple WWDC2017  (0) 2017.10.24
iPhone X's Strategy  (0) 2017.10.13
Tesla's Music Strategy  (0) 2017.10.13

+ Recent posts