반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리

Elements of AI - How neural networks are built

2018. 6. 25. 00:30 | Posted by 솔웅


반응형



Elements of AI



II.How neural networks are built





As we said earlier, neurons are very simple processing units. Having discussed linear and logistic regression in Chapter 4, the essential technical details of neural networks can be seen as slight variations of the same idea.


앞서 말했듯이 뉴런은 매우 간단한 처리 단위입니다. 4 장에서 선형 및 로지스틱 회귀에 대해 배웠습니다., 신경망(neural networks)의 핵심 기술의 세부 사항은 그것들과 같은 아이디어에서 약간의 변형을 한 것일 뿐이라는 것을 아시게 될 겁니다.




Note

Weights and inputs

The basic artificial neuron model involves a set of adaptive parameters, called weights like in linear and logistic regression. Just like in regression, these weights are used as multipliers on the inputs of the neuron, which are added up. The sum of the weights times the inputs is called the linear combination of the inputs. You can probably recall the shopping bill analogy: you multiply the amount of each item by its price per unit and add up to get the total.


기본 artificial neuron 모델은 linear 및 logistic regression에서 사용되는 weights 라고하는 adaptive parameters의 세트를 포함합니다. regression와 마찬가지로, 이러한 weights는 더 해지는 뉴런의 입력에 승수로 사용됩니다. weights에 입력 값을 곱한 값의 합을 linear combination이라고합니다. 우리는 shopping bill analogy를 떠 올릴 수 있습니다. 각 항목당 가격에 그 갯수를 곱한 다음 그것들을 합하여 청구금액을 구했습니다. 





If we have a neuron with six inputs (analogous to the amounts of the six shopping items: potatoes, carrots, and so on), input1, input2, input3, input4, input5, and input6, we also need six weights. The weights are analogous to the prices of the items. We’ll call them weight1, weight2, weight3, weight4, weight5, and weight6. In addition, we’ll usually want to include an intercept term like we did in linear regression. This can be thought of as a fixed additional charge due to processing a credit card payment, for example.



우리가 여섯 개의 입력에 한개의 뉴런을 가지고 있다고 합시다. (6개의 쇼핑 아이템들의 amounts와 유사합니다: 감자, 당근 등등), input1, input2, input3, input4, input5 및 input6과 같은 여섯 개의 입력을 갖는 뉴런을 가지고 있다면 여섯 개의 weights도 필요합니다. weights는 품목 가격과 유사합니다. 우리는 그것을 weight1, weight2, weight3, weight4, weight5 및 weight6이라고합니다. 또한 linear regression에서 했던것과 같은 intercept term을 포함하기를 원합니다. 이것은 예를 들어 신용 카드 지불 처리로 인해 생기는 고정 된 추가 비용이라고 생각할 수 있습니다.




We can then calculate the linear combination like this: linear combination = intercept + weight1 × input1 + ... + weight6 × input6 (where the ... is a shorthand notation meaning that the sum include all the terms from 1 to 6).



그 다음 우리는 다음과 같이 linear combination을 계산할 수 있습니다.

linear combination = intercept + weight1 × input1 + ... + weight6 × input6 

(여기서 ...는 합계에 1에서 6까지의 모든 항이 포함되어 있음을 의미하는 약식 표기입니다.)



With some example numbers we could then get:


숫자로 하면 다음과 같이 됩니다.



10.0 + 5.4 × 8 + (-10.2) × 5 + (-0.1) × 22 + 101.4 × (-5) + 0.0 × 2 + 12.0 × (-3) = -543.0




AWS DeepLens - Deep learning enabled video camera for developers

아마존 AWS DeepLens는 Deep learning을 배울 수 있는 개발자용 비디오 카메라 입니다.
2018년 6월부터 판매하고 있습니다. 구매를 원하시면 위 이미지 링크를 클릭하세요.




Exercise 21: Weights and inputs


In this exercise, consider the following expression that has both weights and inputs: 10.0 + 5.4 × 8 + (-10.2) × 5 + (-0.1) × 22 + 101.4 × (-5) + 0.0 × 2 + 12.0 × (-3) = -543.0




What is the intercept term in the expression? 

a) 543.0 

b) 10.0 

c) -3 

d) 5.4?



What are the inputs? 

a) 8, 5, 22, -5, 2, -3 

b) 5.4, 8, -10.2, 5, -0.1, 22, 101.4, -5, 0.0, 2, 12.0, -3 

c) 5.4, -10.2, -0.1, 101.4, 0.0, 12.0 

d) 43.2, -51.0, -2.2, -507.0, 0.0, -36.0



Which of the inputs needs to be changed the least to increase the output by a certain amount? 

a) first 

b) second 

c) third 

d) fourth



What happens when the fifth input is incremented by one? 

a) nothing 

b) the output increases by one 

c) the output increases by two 

d) something else




The weights are almost always learned from data using the same ideas as in linear or logistic regression, as discussed previously. But before we discuss this in more detail, we’ll introduce another important stage that a neuron completes before it sends out an output signal.



weights는 이전에 논의 된 것처럼 linear 또는 logistic regression 에서와 같은 아이디어를 사용하여 거의 항상 데이터로부터 얻어지게 됩니다. 우리가 좀 더 자세한 것들을 논의하기 전에 다른 중요한 stage를 소개해 드릴 겁니다. 그것은 뉴런이 출력 신호를 보내기 전에 완성하게 되는 것입니다.




Activations and outputs


Once the linear combination has been computed, the neuron does one more operation. It takes the linear combination and puts it through a so called activation function. Typical examples of the activation function include:



일단 linear combination이 계산되면, 뉴런은 한 번 더 연산을 수행합니다. linear combination을 취하여 소위 활성화 함수를 통해 전달합니다. activation function의 일반적인 예는 다음과 같습니다.



  • identity function: do nothing and just output the linear combination
  • step function: if the value of the linear combination is greater than zero, send a pulse (ON), otherwise do nothing (OFF)
  • sigmoid function: a “soft” version of the step function


- identity function : 아무것도 하지 않고 선형 조합 만 출력합니다.

- step function : linear combination의 값이 0보다 큰 경우 펄스를 보내고 (ON), 그렇지 않으면 아무 것도 하지 않습니다 (OFF)

- sigmoid function : 스텝 함수의 "soft"버전




Note that with the first activation function, the identity function, the neuron is exactly the same as linear regression. This is why the identity function is rarely used in neural networks: it leads to nothing new and interesting.


첫 번째 activation function 인 identity function의 경우, 뉴런은 linear regression와 정확히 동일합니다. 이것이 identity function이 neural networks에서 거의 사용되지 않는 이유입니다. 그것은 새롭고 흥미로운 것은 없습니다.



Note

How neurons activate

Real, biological neurons communicate by sending out sharp, electrical pulses called “spikes”, so that at any given time, their outgoing signal is either on or off (1 or 0). The step function imitates this behavior. However, artificial neural networks tend to use the second kind of activation functions so that they output a continuous numerical activation level at all times. Thus, to use a somewhat awkward figure of speech, real neurons communicate by something similar to the Morse code, whereas artificial neurons communicate by adjusting the pitch of their voice as if yodeling.


실제, 생물학적 뉴런은 "스파이크 (spikes)"라고하는 날카로운 전기 펄스를 전송함으로써 communicate 합니다. 즉 어떤 주어진 시간에 발신 신호가 켜지거나 꺼지게 됩니다 (1 또는 0). step function는 이 동작을 모방합니다. 그러나 artificial neural은 항상 두 번째 종류의 activation functions을 사용하려고 합니다. 그래서 지속적으로 numerical activation level을 출력합니다. 약간 이상한 표현을 하면 실제 뉴런은 모르스 부호와 비슷한 방식으로 의사 소통하는 반면, 인공 뉴런은 그들의 요괴와 같은 목소리를 조정함으로서 소통을 합니다.




The output of the neuron, determined by the linear combination and the activation function, can be used to extract a prediction or a decision. For example, if the network is designed to identify a stop sign in front of a self-driving car, the input can be the pixels of an image captured by a camera attached in front of the car, and the output can be used to activate a stopping procedure that stops the car before the sign.



linear combination 및 activation function에 의해 결정되는 뉴런의 출력은 예측 또는 결정을 추출하는 데 사용될 수 있습니다. 예를 들어, 그 네트워크가 주율 주행 중인 자동차 앞에서 정지 신호를 식별하도록 설계된 경우, 입력은 자동차 앞쪽에 부착 된 카메라로 캡처 한 이미지의 픽셀 일 수 있으며 출력을 사용하여 표지판 앞에서 차를 멈추는 정지 절차를 실행하게 됩니다.



Learning or adaptation in the network occurs when the weights are adjusted so as to make the network produce the correct outputs, just like in linear or logistic regression. Many neural networks are very large, and the largest contain hundreds of billions of weights. Optimizing them all can be a daunting task that requires massive amounts of computing power.



linear 또는 logistic regression와 마찬가지로 네트워크가 올바른 출력을 생성 할 수 있도록 weights가 조정될 때 네트워크에서의 학습(Learning) 또는 적응(adaptation)이 발생합니다. 많은 neural networks들은 그 규모가 매우 크며, 가장 큰 신경망은 수천억 개의 weights를 포함합니다. 이들 모두를 최적화하는 것은 엄청난 양의 컴퓨팅 능력을 요구하는 어려운 작업 일 수 있습니다.







Exercise 22: Activations and outputs

Below are graphs for three different activation functions with different properties. First we have the sigmoid function, then the step function, and finally the identity function.


다음은 서로 다른 특성을 가진 세 가지 다른 activation functions에 대한 그래프입니다. 먼저 sigmoid functions, step functions, 마지막으로 identity functions를 사용합니다.













Which of the activations described above give: 

the largest output for an input of 5?

Sigmoid

Linear

Step


the smallest output for an input of -5?

Sigmoid

Linear

Step


the largest output for an input of -2.5?

Sigmoid

Linear

Step




Perceptron: the mother of all ANNs


The perceptron is simply a fancy name for the simple neuron model with the step activation function we discussed above. It was among the very first formal models of neural computation and because of its fundamental role in the history of neural networks, it wouldn’t be unfair to call it the “Mother of all Artificial Neural Networks”.



perceptron은 위에서 논의한 step activation function가있는 간단한 뉴런 모델의 멋진 이름입니다. 그것은 neural computation의 최초의 공식 모델 중 하나 였고 신경망의 역사에서 기초가 되는 역할을 하기 때문에 "모든 Artificial Neural Networks의 어머니"라고 부른다고 해서 틀린 말은 아닙니다.



It can be used as a simple classifier in binary classification tasks. A method for learning the weights of the perceptron from data, called the Perceptron algorithm, was introduced by the psychologist Frank Rosenblatt in 1957. We will not study the Perceptron algorithm in detail. Suffice to say that it is just about as simple as the nearest neighbor classifier. The basic principle is to feed the network training data one example at a time. Each misclassification leads to an update in the weight.



이진 분류(binary classification) 작업에서 간단한 classifier로 사용될 수 있습니다. 퍼셉트론 (Perceptron) 알고리즘이라고 불리는 데이터로부터 퍼셉트론의 가중치를 학습하는 방법은 1957 년 심리학자 Frank Rosenblatt에 의해 도입되었습니다. 우리는 Perceptron 알고리즘을 자세히 연구하지는 않을 것입니다. 그것이 nearest neighbor classifier만큼이나 간단하다고 말할 수 있습니다. 기본 원리는 한 번에 한 가지 예를 들어 네트워크 교육 데이터를 제공하는 것입니다. 각 misclassification에 대해서는 weight가 업데이트됩니다.




Note

AI hyperbole

After its discovery, the Perceptron algorithm received a lot of attention, not least because of optimistic statements made by its inventor, Frank Rosenblatt. A classic example of AI hyperbole is a New York Times article published on July 8th, 1958:
“The Navy revealed the embryo of an electronic computer today that it expects will be able to walk, talk, see, reproduce itself and be conscious of its existence.”

Please note that neural network enthusiasts are not at all the only ones inclined towards optimism. The rise and fall of the logic-based expert systems approach to AI had all the same hallmark features of an AI-hype and people claimed that the final breakthrough is just a short while away. The outcome both in the early 1960s and late 1980s was a collapse in the research funding called an AI Winter.


Perceptron 알고리즘을 발견 한 후 이는 많은 주목을 받았는데, 그 이유는 적어도 발명자 인 Frank Rosenblatt가 말한 낙관적 인 진술(optimistic statements) 때문이었습니다. AI hyperbole의 고전적인 예는 1958 년 7 월 8 일에 출판 된 New York Times의 기사입니다.

"해군은 오늘 전자 컴퓨터의 배아가 걸을 수 있고, 말하고,보고, 복제하고, 존재를 의식 할 수있을 것으로 기대한다고 밝혔다.


신경망 애호가가 낙관적 인 경향이있는 것은 아닙니다. AI에 대한 logic-based expert systems 접근법의 인기 상승과 하락은 AI-hype(과장된 AI)의 그것과 거의 같이 갔습니다. 사람들은 최종 목표 지점이 얼마 안 남았다고 주장했죠. 1960 년대 초반과 1980 년대 후반의 두 접근법이 보여준 결과는 AI Winter라고하는 연구 기금의 붕괴였다.




The history of the debate that eventually lead to almost complete abandoning of the neural network approach in the 1960s for more than two decades is extremely fascinating. The article A Sociological Study of the Official History of the Perceptrons Controversy by Mikel Olazaran (published in Social Studies of Science, 1996) reviews the events from a sociology of science point of view. Reading it today is quite thought provoking. Reading stories about celebrated AI heroes who had developed neural networks algorithms that would soon reach the level of human intelligence and become self-conscious can be compared to some statements made during the current hype. If you take a look at the above article, even if you wouldn't read all of it, it will provide an interesting background to today's news. Consider for example an article in the MIT Technology Review published in September 2017, where Jordan Jacobs, co-founder of a multimillion dollar Vector institute for AI compares Geoffrey Hinton (a figure-head of the current deep learning boom) to Einstein because of his contributions to development of neural network algorithms in the 1980s and later. Also recall the Human Brain project mentioned in the previous section.



결국 20 년 넘게 계속된 1960 년대식 neural network 접근법이 완전히 포기하게 되는 과정의 논쟁은 아주 많이 흥미롭습니다. 미켈 올 라자 란 (Mikel Olazaran)의 퍼셉트론 논란 (Perceptrons Controversy)의 공식 역사에 관한 사회 학적 연구 (1996 년 사회학 출판)는 과학적 관점에서 사회학의 사건을 검토합니다. 오늘 그것을 읽는 것은 상당히 자극적이라고 생각합니다. 곧 인간 지능 수준에 도달하고 자의식이되는 신경 회로망 알고리즘을 개발 한 유명한 AI 영웅에 관한 이야기를 읽는 것은 현재 과대 광고 중에 작성된 일부 표현과 비교할 수 있습니다. 위의 기사를 살펴보면 모든 기사를 읽지 않더라도 오늘의 뉴스에 흥미로운 배경을 제공합니다. 예를 들어, 2017 년 9 월에 발표 된 MIT Technology Review의 기사에서 인공 지능을 위한 수백만 달러짜리 벡터 neural network 알고리즘의 개발에 공헌한 정도를 아인슈타인과 비교하기도 합니다. 이전 섹션에서 언급 한 Human Brain 프로젝트를 상기 해보십시오.



According to Hinton, “the fact that it doesn’t work is just a temporary annoyance.” (Although according to the article, Hinton is laughing about the above statement, so it's hard to tell how serious he is about it.) The Human Brain project claims to be “close to a profound leap in our understanding of consciousness“. Doesn't that sound familiar?



Hinton에 따르면, "그것이 제대로 작동하지 않는다는 팩트는 그냥 일시적인 불편함일 뿐이다."(기사에 따르면 Hinton은 위의 문장에 대해 웃음을 짓고 있지만 그가 얼마나 그것에 대해 serious 했는지에 대해서는 자세하 알 수 없습니다.) The uman Brain 프로젝트는 "의식에 대한 우리의 이해에 있어 중대한 도약에 가깝다"고 주장합니다. 왠지 그 표현이 귀에 익숙하지 않으세요?



No-one really knows the future with certainty, but knowing the track record of earlier annoucements of imminent breakthroughs, some critical thinking is advised. We'll return to the future of AI in the final Chapter, but for now, let's see how artificial neural networks are built.


아무도 확실하게 미래를 알지 못하지만, 그것을 해결하기 위해 연구한 이전에 발표 들을 따라가다 보면 더 낳은 어떤 중요한(비판적인) 생각들을 할 수 있습니다.  우리는 마지막 장에서 인공 지능의 미래로 돌아갈 것이지만, 지금은 인공 신경 네트워크가 어떻게 만들어 지는지 보도록하겠습니다.




Putting neurons together: networks



A single neuron would be way too simple to make decisions and prediction reliably in most real-life applications. To unleash the full potential of neural networks, we can use the the output of one neuron as the input of other neurons, whose outputs can be the input to yet other neurons, and so on. The output of the whole network is obtained as the output of a certain subset of the neurons, which are called the output layer. We’ll return to this in a bit, after we discussed the way neural networks adapt to produce different behaviors by learning their parameters from data.



하나의 뉴런은 대부분의 실제 애플리케이션에서 안정적으로 의사 결정과 예측을 내리기에는 너무 단순합니다. 신경 네트워크의 모든 잠재력을 발휘하기 위해 우리는 한 뉴런의 출력을 다른 뉴런의 입력으로 사용할 수 있으며 그 출력은 다른 뉴런에 대한 입력이 될 수 있어야 합니다. 전체 네트워크의 출력은 출력 레이어라고하는 뉴런의 특정 하위 집합의 출력으로 얻어집니다. 우리는 신경 네트워크가 데이터로부터 매개 변수를 학습함으로써 다른 행동을 생산하는 방식에 대해 논의한 후에 이 부분으로 조금 돌아가 보겠습니다.



Key terminology

Layers

Often the network architecture is composed of layers. The input layer consists of neurons that get their inputs directly from the data. So for example, in an image recognition task, the input layer would use the pixel values of the input image as the inputs of the input layer. The network typically also has hidden layers that use the other neurons´ outputs as their input, and whose output is used as the input to other layers of neurons. Finally, the output layer produces the output of the whole network. All the neurons on a given layer get inputs from neurons on the previous layer and feed their output to the next.


종종 네트워크 아키텍처는 레이어로 구성됩니다. 입력 레이어는 데이터에서 직접 입력을받는 뉴런으로 구성됩니다. 예를 들어 이미지 인식 작업에서 입력 레이어는 입력 이미지의 픽셀 값을 입력 레이어의 입력으로 사용합니다. 네트워크는 일반적으로 입력으로 다른 뉴런의 출력을 사용하는 숨겨진 레이어가 있으며, 출력은 뉴런의 다른 레이어에 대한 입력으로 사용됩니다. 마지막으로 출력 레이어는 전체 네트워크의 출력을 생성합니다. 주어진 레이어의 모든 뉴런은 이전 레이어의 뉴런에서 입력을 받아 다음 레이어로 출력합니다.




A classical example of a multilayer network is the so called multilayer perceptron. As we discussed above, Rosenblatt’s Perceptron algorithm can be used to learn the weights of a perceptron. For multilayer perceptron, the corresponding learning problem is way harder and it took a long time before a working solution was discovered. But eventually, one was invented: the so called backpropagation algorithm lead to a revival of neural networks in the late 1980s. It is still at the heart of many of the most advanced deep learning solutions.



다층 네트워크의 고전적인 예는 소위 다층 퍼셉트론 (multilayer perceptron)이라고 합니다. 위에서 언급했듯이 Rosenblatt의 Perceptron 알고리즘을 사용하여 퍼셉트론의 weights를 학습 할 수 있습니다. 다층 퍼셉트론의 경우, 해당 학습 문제가 더욱 어렵습니다. 그 작업의 솔루션을 발견하기까지는 더 많은 시간이 걸릴겁니다. 그러나 결과적으로, 하나는 발명되었습니다. : 소위 역 전파 알고리즘은 1980 년대 후반에 신경 회로망을 부활시키게 됩니다. 그것은 여전히 가장 진보 된 많은 deep learning 솔루션의 핵심입니다.



Note

Meanwhile in Helsinki...

The path(s) leading to the backpropagation algorithm are rather long and winding. An interesting part of the history is related to the computer science department of the University of Helsinki. About three years after the founding of the department in 1967, a Master’s thesis was written by a student called Seppo Linnainmaa. The topic of the thesis was “Cumulative rounding error of algorithms as a Taylor approximation of individual rounding errors” (the thesis was written in Finnish, so this is a translation of the actual title “Algoritmin kumulatiivinen pyöristysvirhe yksittäisten pyöristysvirheiden Taylor-kehitelmänä”).

The automatic differentiation method developed in the thesis was later applied by other researchers to quantify the sensitivity of the output of a multilayer neural network with respect to the individual weights, which is the key idea in backpropagation.


backpropagation 알고리즘으로 이끄는 길은 다소 길며 어려움이 있습니다. 그 역사에서 흥미로운 부분은 헬싱키 대학의 컴퓨터 과학과 관련되어 있습니다. 1967 년에 학과가 창립 된 지 약 3 년 후, Seppo Linnainmaa라는 학생이 석사 논문을 썼습니다. 이 논문의 주제는 "Cumulative rounding error of algorithms as a Taylor approximation of individual rounding errors" (논문은 핀란드어로 작성되었으므로 실제 제목 인 "Algoritmin kumulatiivinen pyöristysvirhe yksittäist pyöristysvirheiden Taylor-kehitelmänä"번역본)입니다.


이 논문에서 개발 된 자동 차별화 (automatic differentiation) 방법은 다른 연구원에 의해 나중에 역 전파에서 핵심 아이디어 인 개별 가중치에 대한 다층 신경망 출력의 민감도를 정량화하기 위해 적용되었습니다.



A simple neural network classifier


To give a relatively simple example of using a neural network classifier, we'll consider a task that is very similar to the MNIST digit recognition task, namely classifying images in two classes. We will first create a classifier to classify whether an image shows a cross (x) or a circle (o). Our images are represented here as pixels that are either colored or white, and the pixels are arranged in 5 × 5 grid. In this format our images of a cross and a circle (more like a diamond, to be honest) look like this:


neural network classifier를 사용하는 비교적 간단한 예제를 제공하기 위해, 우리는 MNIST digit recognition 태스크와 매우 유사한 태스크, 즉 2 개의 클래스로 이미지를 분류하는 태스크를 살펴 볼 겁니다. 먼저 이미지에 가위 표시 (x) 또는 원 (o) 표시 여부를 분류하는 분류자(classifier)를 만듭니다. 우리의 이미지는 여기에 색깔이 있거나 흰색 인 픽셀로 표현되며 픽셀은 5x5 격자로 배열됩니다. 이 형식에서는 가위표시와 원 (솔직히 다이아몬드와 더 비슷합니다.)의 이미지가 다음과 같이 보입니다.






In order to build a neural network classifier, we need to formalise the problem in a way where we can solve it using the methods we have learned. Our first step is to represent the information in the pixels by a numerical values that can be used as the input to a classifier. Let's use 1 if the square is colored, and 0 if it is white. Note that although the symbols in the above graphic are of different color (green and blue), our classifier will ignore the color information and use only the colored/white information. The 25 pixels in the image make the inputs of our classifier.



neural network classifier를 만들기 위해서는 우리가 배운 방법을 사용하여 문제를 공식화해야합니다. 첫 번째 단계는 픽셀의 정보를 분류 기준의 입력으로 사용할 수있는 숫자 값으로 표현하는 것입니다. 사각형에 색이 칠해지면 1을, 흰색이면 0을 사용하기로 하겠습니다. 위의 그림에서는 다른 색상 (녹색 및 파란색)이지만 우리의 classifier는 색상 정보를 무시하고 colored/white 만 사용할 겁니다. 이미지에 있는 25개의 픽셀이 우리의 classifier의 입력을 만듭니다.



To make sure that we know which pixel is which in the numerical representation, we can decide to list the pixels in the same order as you'd read text, so row by row from the top, and reading each row from left to right. The first row of the cross, for example, is represented as 1,0,0,0,1; the second row as 0,1,0,1,0, and so on. The full input for the cross input is then: 1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1.



어떤 픽셀이 어떤 숫자 인지 알기 위해 텍스트를 읽는 순서와 같은 순서로 픽셀을 나열하기 때문에 위쪽에서 행 단위로 정렬하고 각 행을 왼쪽에서 오른쪽으로 읽는 방식으로 결정할 수 있습니다. 예를 들어 십자가의 첫 번째 행은 1,0,0,0,1로 표시됩니다. 두 번째 행은 0,1,0,1,0과 같이 나타납니다. 가위표에 대한 전체 입력은 다음과 같습니다. 1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,1,0, 1,0,0,0,1.



We'll use the basic neuron model where the first step is to compute a linear combination of the inputs. Thus need a weight for each of the input pixels, which means 25 weights in total.


첫 번째 단계는 입력의 linear combination을 계산하는 기본 뉴런 모델을 사용합니다. 따라서 각 입력 픽셀에 대해 weight가 필요합니다. 즉 총 25 개의 weight를 의미합니다.



Finally, we use the step activation function. If the linear combination is negative, the neuron activation is zero, which we decide to use to signify a cross. If the linear combination is positive, the neuron activation is one, which we decide to signify a circle.


마지막으로 step activation function를 사용합니다. linear combination이 음수이면 뉴런 활성화는 0이며 가위표를 나타내는 데 사용하기로 결정합니다. 선형 조합이 양수이면, 뉴런 활성화는 하나이며, 이는 우리가 원을 나타 내기로 결정한 것입니다.



Let's try what happens when all the weights take the same numerical value, 1. With this setup, our linear combination for the cross image will be 9 (9 colored pixels, so 9 × 1, and 16 white pixels, 16 × 0), and for the circle image it will be 8 (8 colored pixels, 8 × 1, and 17 white pixels, 17 × 0). In other words, the linear combination is positive for both images and they are thus classified as circles. Not a very good result given that there are only two images to classify.



모든 weights가 동일한 숫자 값 1을 사용하면 어떻게되는지 시도해 봅시다. 이 설정을 사용하면 가위표 이미지에 대한 선형 조합이 9 (9 colored pixels, so 9 × 1, and 16 white pixels, 16 × 0)가 됩니다. 원 이미지의 경우 8 (8 colored pixels, 8 × 1, and 17 white pixels, 17 × 0)이 됩니다. 즉, linear combination은 두 이미지에 대해 양의 값을 갖기 때문에 원으로 분류됩니다. 분류 할 이미지가 두 개 뿐인 경우 매우 좋은 결과는 아니죠.



To improve the result, we need to adjust the weights in such a way that the linear combination will negative for a cross and positive for a circle. If we think about what differentiates images of crosses and circles, we can see that circles have no colored pixels in the center of the image, whereas crosses do. Likewise, the pixels at the corners of the image are colored in the cross, but white in the circle.



결과를 개선하려면 linear combination이 가위표에 대해 음수이고 원에 대해 양수가되는 방식으로 가중치를 조정해야합니다. 가위표와 원의 이미지를 구별하는 것에 대해 생각해 보면 원은 이미지의 중심에 컬러 픽셀이없고 십자가는 볼 수 있습니다. 마찬가지로 이미지 모서리에있는 픽셀은 십자가에 표시되지만 원에는 흰색으로 표시됩니다.



We can now adjust the weights. There are an infinite number of weights that do the job. For example, assign weight -1 to the center pixel (the 13th pixel), and weight 1 to the pixels in the middle of each of the four sides of the image, letting all the other weights be 0. Now, for the cross input, the center pixel produce the value –1, while for all the other pixels either the pixel value of the weight is 0, so that –1 is also the total value. This leads to activation 0, and the cross is correctly classified.



이제 우리는 weights를 조정할 수 있습니다. 그 일을 하는 무한한 가중치가 있습니다. 예를 들어, 중심 픽셀 (13 번째 픽셀)에 가중치 -1을 할당하고 이미지의 네면의 중간에있는 픽셀에 가중치 1을 할당하여 다른 모든 가중치를 0으로 만듭니다. 이제 교차 입력 중심 픽셀은 값 -1을 생성하지만 다른 모든 픽셀에 대해서는 가중치의 픽셀 값이 0이므로 -1도 총 값입니다. 이로 인해 활성화 0이 발생하고 가위표가 올바르게 분류됩니다.



How about the circle then? Each of the pixels in the middle of the sides produces the value 1, which makes 4 × 1 = 4 in total. For all the other pixels either the pixel value or the weight is zero, so 4 is the total. Since 4 is a positive value, the activation is 1, and the circle is correctly recognized as well.



그럼 원은? 변의 중간에있는 각 픽셀은 값 1을 생성하며, 총 4 × 1 = 4가됩니다. 다른 모든 픽셀의 경우 픽셀 값 또는 가중치가 0이므로 4가 합계입니다. 4가 양수이므로 활성화는 1이며 원이 올바르게 인식됩니다.




Happy or not?


We will now follow similar reasoning to build a classifier for smiley faces. You can assign weights to the input pixels in the image by clicking on them. Clicking once sets the weight to 1, and clicking again sets it to -1. The activation 1 indicates that the image is classified as a happy face, which can be correct or not, while activation –1 indicates that the image is classified as a sad face.


우리는 똑같은 추론(reasoning)을 따라 웃는 얼굴을위한 classifier를 만들 것입니다. 이미지의 입력 픽셀을 클릭하여 weights를 지정할 수 있습니다. 한 번 클릭하면 weights가 1로 설정되고 다시 클릭하면 -1로 설정됩니다. 활성화 1은 이미지가 행복한 얼굴로 분류됨을 나타내며, 활성화 -1은 이미지가 슬픈 얼굴로 분류되었음을 나타냅니다.



Don't be discouraged by the fact that you will not be able to classify all the smiley faces correctly: it is in fact impossible with our simple classifier! This is one important learning objective: sometimes perfect classification just isn't possible because the classifier is too simple. In this case the simple neuron that uses a linear combination of the inputs is too simple for the task. Observe how you can build classifiers that work well in different cases: some classify most of the happy faces correctly while being worse for sad faces, or the other way around.


모든 웃는 얼굴을 정확하게 분류 할 수 없다는 사실로 인해 낙담하지 마십시오. 우리의 간단한 classifier로는 실제로 불가능합니다! 이는 중요한 학습 목표 중 하나입니다. classifier가 너무 간단하기 때문에 완벽한 분류가 불가능한 경우도 있습니다. 이 경우 입력의 선형 조합을 사용하는 단순한 뉴런은 이 작업을 하기에 너무 간단합니다. 다른 경우에 잘 작동하는 classifier를 제작하는 방법을 관찰하십시오. 일부는 행복한 얼굴 대부분을 올바르게 분류하고 슬픈 얼굴이나 그 반대의 경우에도 마찬가지 입니다.



Can you achieve 6/8 correct for both happy and sad faces?







반응형