<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://hodurie.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://hodurie.github.io/" rel="alternate" type="text/html" /><updated>2020-08-29T17:08:50+09:00</updated><id>https://hodurie.github.io/feed.xml</id><title type="html">Hodurie’s Blog</title><subtitle>이것 저것 저장소</subtitle><author><name>Hodurie</name></author><entry><title type="html">선형대수학 - 01. Vector</title><link href="https://hodurie.github.io/study/LinearAlgebra" rel="alternate" type="text/html" title="선형대수학 - 01. Vector" /><published>2020-08-28T00:00:00+09:00</published><updated>2020-08-28T00:00:00+09:00</updated><id>https://hodurie.github.io/study/LA-Vector</id><content type="html" xml:base="https://hodurie.github.io/study/LinearAlgebra">&lt;p&gt;본 글은 edwith &lt;a href=&quot;https://www.edwith.org/linear-algebra/lecture/30304/&quot;&gt;[칸아카데미] 모두를 위한 선형대수학&lt;/a&gt;를 참고하여 작성하였습니다.&lt;/p&gt;
&lt;h1 id=&quot;선형-대수학---01-벡터&quot;&gt;선형 대수학 - 01. 벡터&lt;/h1&gt;
&lt;h2 id=&quot;선형-대수학&quot;&gt;선형 대수학&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;벡터 공간, 벡터, 선형 변환, 행렬, 연립 선형 방정식을 연구하는 대수학의 한 분야&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;벡터&quot;&gt;벡터&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;벡터 공간의 원소
    &lt;blockquote&gt;
      &lt;p&gt;벡터 공간이란?  &lt;br /&gt;
선행 대수학에서 원소를 서로 더하거나,&lt;br /&gt;
주어진 배수로 늘이거나 줄일 수 있는 공간&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;방향과 속도를 갖는 값&lt;/li&gt;
  &lt;li&gt;속도만 갖고 방향을 갖지 않는 값은 스칼라&lt;/li&gt;
  &lt;li&gt;위치와 상관없이, 방향과 속도가 같으면 동일한 벡터&lt;/li&gt;
  &lt;li&gt;변수로 사용할 경우 알파벳 위에 화살표를 표현함 
$\vec{v} = (x, y) = 
\left[\begin{array}{r}
x&lt;br /&gt;
y
\end{array}\right]
$&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;실좌표-공간&quot;&gt;실좌표 공간&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;$\mathbb{R}^n$ 또는 &lt;strong&gt;$\mathbf{R}^n$&lt;/strong&gt;은 $n$차원 실수 좌표 공간을 나타냄&lt;/li&gt;
  &lt;li&gt;$\mathbb{R}^n$은 $n$의 값을 갖는 튜플
    &lt;blockquote&gt;
      &lt;p&gt;튜플이란?&lt;br /&gt;
순서가 정해진 셀 수 있는 값들을 열거한 값으로,&lt;br /&gt;
$n$개의 요소를 가지면 &lt;strong&gt;$n$-튜플&lt;/strong&gt;이라 한다.&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;$\vec{x} = (0, 1)$ 실수 값을 갖는 다면 $\vec{x} \in \mathbb{R^2}$&lt;/li&gt;
  &lt;li&gt;$\vec{x} = (-i,i)$ 허수의 값을 갖는 다면, $\vec{x} \notin \mathbb{R^2}$&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;대수와-그래프를-이용한-벡터의-덧셈&quot;&gt;대수와 그래프를 이용한 벡터의 덧셈&lt;/h2&gt;
&lt;p&gt;$\vec{a} ,  \vec{b} \in\mathbb{R^2}$ 이고,&lt;br /&gt;
$\vec{a} = (6, -2),  \vec{b} = (-4, 4)$ 일 때&lt;br /&gt;
$\vec{a} + \vec{b} = (6 + (-4), (-2) + 4) = (2, 2)$&lt;br /&gt;
&lt;img src=&quot;./LinearAlgebra/vector.png&quot; alt=&quot;plus&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;벡터와-스칼라의-곱셈&quot;&gt;벡터와 스칼라의 곱셈&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;벡터에 스칼라 곱을 하면 각 원소에 스칼라 값을 곱한 값과 같다.&lt;br /&gt;
$\vec{a} \in\mathbb{R^2}$ 이고, &lt;br /&gt;
$\vec{a} = (2, 1)$ &lt;br /&gt;
$3\vec{a} = (3&lt;em&gt;2, 3&lt;/em&gt;1) = (6, 3)$&lt;/li&gt;
  &lt;li&gt;벡터에 양수 스칼라곱은 방향을 유지한 채 크기만 스칼라배 해준다.&lt;/li&gt;
  &lt;li&gt;벡터에 음수 스칼라곱은 벡터의 정반대 방향으로 스칼라배 해준다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;대수와-그래프를-이용한-벡터의-뺄셈&quot;&gt;대수와 그래프를 이용한 벡터의 뺄셈&lt;/h2&gt;
&lt;p&gt;$\vec{a} ,  \vec{b} \in\mathbb{R^2}$ 이고,&lt;br /&gt;
$\vec{a} = (3, -2),  \vec{b} = (1, 2)$ 일 때&lt;br /&gt;
$\vec{a} - \vec{b} = (3 - 1, (-2) - 2) = (2, -4)$&lt;br /&gt;
&lt;img src=&quot;./LinearAlgebra/vector1.png&quot; alt=&quot;minus&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;벡터1 - 벡터2 를 하게 되면, 각 벡터의 끝점을 이은 선분이 된다.&lt;/li&gt;
  &lt;li&gt;두 벡터의 뺼셈의 방향은 벡터1의 끝점을 향하게 한다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;단위-벡터&quot;&gt;단위 벡터&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;길이가 1인 벡터&lt;/li&gt;
  &lt;li&gt;벡터 $v$와 방향이 같은 벡터는 $\hat{v}$로서 표기한다.
$\vec{v} \in \mathbb{R}^2$에서&lt;br /&gt;
$\vec{v} = (2, 3)$ 이라 할 때,&lt;br /&gt;
$\vec{v}$는 $x$ 축으로 2, $y$ 축으로 3만큼 갔다고 할 수 있다.&lt;br /&gt;
이때, 길이가 1인 단위 벡터가 있다고 하자.&lt;br /&gt;
$\hat{i}$는 $x$ 축으로 1만큼 $y$ 축으로는 0만큼&lt;br /&gt;
$\hat{j}$는 $x$ 축으로 0만큼 $y$ 축으로는 1만큼 &lt;br /&gt;
즉,&lt;br /&gt;
$\hat{i} = (1, 0) \ \hat{j} = (0, 1)$ &lt;br /&gt;
와 같이 표기하면, $\vec{v}$ 는 위의 단위 벡터의 스칼라 배를 한 단위 벡터의 합으로 표현 할 수 있다. &lt;br /&gt;
$\vec{v} = 2\hat{i} + 3\hat{j}$&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;직선의-매개변수-표현&quot;&gt;직선의 매개변수 표현&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;매개변수, 파라미터, 모수는 함수의 특정한 성질을 나타내는 변수이다.&lt;/li&gt;
  &lt;li&gt;$\theta$로 표시한다.
$\vec{v} \in \mathbb{R}^2$이고,&lt;br /&gt;
${c\vec{v} | c \in \mathbb{R}}$ 일 때,&lt;br /&gt;
영점을 기준으로 $\vec{v}$에 $c$를 무한하게 곱하게 되면,&lt;br /&gt;
하나의 직선이 나오게 된다.&lt;br /&gt;
이를, $\vec{x} \in \mathbb{R}^2$인&lt;br /&gt;
$\vec{x}$ 만큼 이동하게 되면,&lt;br /&gt;
위의 값을 $y = ax + b$로 일반화 할 수 있다.&lt;br /&gt;
이를 두 개의 벡터를 이용해 일반화 하게 되면,&lt;br /&gt;
$\vec{a}, \vec{b} \in \mathbb{R}^2$ 이고,  &lt;br /&gt;
${t|t \in \mathbb{R} }$ 일 때&lt;br /&gt;
$\vec{a} - \vec{b}$를 $t$ 배 한 직선을 원 점으로 옮기면,&lt;br /&gt;
이를 이와 같이 일반화 할 수 있다.&lt;br /&gt;
$L = {\vec{a} + t(\vec{b} - \vec{a}) | t \in \mathbb{R}^2}$  또는&lt;br /&gt;
$L = {\vec{b} + t(\vec{b} - \vec{a}) | t \in \mathbb{R}^2}$&lt;br /&gt;
여기서 특정 위치의 $x, y$의 좌표를 구하려면,&lt;br /&gt;
각 원소들의 합들로 나타낼 수 있다.&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Hodurie</name></author><category term="[&quot;Math&quot;]" /><category term="Linear Algebra" /><summary type="html">본 글은 edwith [칸아카데미] 모두를 위한 선형대수학를 참고하여 작성하였습니다. 선형 대수학 - 01. 벡터 선형 대수학 벡터 공간, 벡터, 선형 변환, 행렬, 연립 선형 방정식을 연구하는 대수학의 한 분야</summary></entry><entry><title type="html">Linked List 01</title><link href="https://hodurie.github.io/study/java/Linked_List" rel="alternate" type="text/html" title="Linked List 01" /><published>2020-06-14T00:00:00+09:00</published><updated>2020-06-14T00:00:00+09:00</updated><id>https://hodurie.github.io/study/java/Linked_List</id><content type="html" xml:base="https://hodurie.github.io/study/java/Linked_List">&lt;p&gt;본 글은 &lt;a href=&quot;https://www.youtube.com/user/damazzang&quot;&gt;엔지니어대한민국&lt;/a&gt;를 참고하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;linked-list&quot;&gt;Linked List&lt;/h1&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Linked List&lt;/code&gt;를 이해하기 위해선 일단 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Array&lt;/code&gt;를 알아야한다.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Array&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;변수가 선언 되고 나서 크기 변경 불가&lt;/li&gt;
  &lt;li&gt;메모리 상에서 물리적으로 연결 돼 있음&lt;/li&gt;
  &lt;li&gt;저장 된 순서에 따라 값을 추출 할 수 있음&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Linked List&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;변수가 선언 되고 나서 크기 변경 가능&lt;/li&gt;
  &lt;li&gt;메모리 상에서 물리적으로 연결 돼 있지 않음&lt;/li&gt;
  &lt;li&gt;하나의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;가 값과 다음 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소를 저장하고 있음&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;linked-list-단양-방향&quot;&gt;Linked List 단/양 방향&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;단방향&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;다음 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소값 보유&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;양방향&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;이전의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소값과 다음 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소값 보유&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt; 삽입 시 : 이전 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소값과 다음 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소값 보유&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt; 삭제 시 : 다음 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소값을 이전 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소값에 할당, 이전 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 주소값을 다음 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list&lt;/code&gt;의 할당&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;구현-in-java-단방향&quot;&gt;구현 in Java (단방향)&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
				&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
				&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
			&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;retrieve&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; -&amp;gt; &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SinglyLinkedList&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;retrieve&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SinglyLinkedList&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;retrieve&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;retrieve&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="java" /><category term="Data Structure" /><summary type="html">본 글은 엔지니어대한민국를 참고하여 작성하였습니다.</summary></entry><entry><title type="html">Softmax Regression(Multinomial Logistic Regression) 01</title><link href="https://hodurie.github.io/study/ai/ML_Lec_06_01" rel="alternate" type="text/html" title="Softmax Regression(Multinomial Logistic Regression) 01" /><published>2020-05-21T00:00:00+09:00</published><updated>2020-05-21T00:00:00+09:00</updated><id>https://hodurie.github.io/study/ai/ML-Lec-06-01</id><content type="html" xml:base="https://hodurie.github.io/study/ai/ML_Lec_06_01">&lt;p&gt;본 글은 &lt;a href=&quot;https://hunkim.github.io/ml/&quot;&gt;모두를 위한 머신러닝/딥러닝 강의&lt;/a&gt;를 참고하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;ml-lec-6-1---softmax-regression&quot;&gt;ML lec 6-1 - Softmax Regression&lt;/h1&gt;
&lt;p&gt;이전에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Binary classification&lt;/code&gt;에 대해 다뤘다.&lt;/p&gt;

&lt;p&gt;오늘은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Multinomial classification&lt;/code&gt;에 대해 알아보겠다.&lt;/p&gt;

&lt;h2 id=&quot;multinomial-classification&quot;&gt;Multinomial Classification&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Multinomial Classification&lt;/code&gt;은 세 개 이상의 값을 분류하는 방법이다.&lt;/p&gt;

&lt;p&gt;이를 설명하기 위해선 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;binary classification&lt;/code&gt;의 이해를 바탕으로 해야한다.&lt;/p&gt;

&lt;p&gt;예를들어,&lt;br /&gt;
$A, B, C$란 값이 존재할 때,&lt;br /&gt;
하나만 잘 분류하는 선분이 있다고 가정하자.&lt;br /&gt;
그럼 각 선분은 아래와 같이 정의 할 수 있다.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;첫 번째 선분은 $A$와 아닌것&lt;/li&gt;
  &lt;li&gt;두 번째 선분은 $B$와 아닌것&lt;/li&gt;
  &lt;li&gt;세 번째 선분은 $C$와 아닌것&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;위 선분을 가지고 값을 분류할 수 있는 분류기를 만들면,&lt;br /&gt;
$x$값이 주어졌을 때 어떤 값인지에 대해 $w$인 가중치를 주고,&lt;br /&gt;
이를 분별하는 함수(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sigmoid&lt;/code&gt;)에 통과시킨다.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sigmoid&lt;/code&gt; : 이항 분류떄 사용하는 함수&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;함수를 통과한 값은 특정 $y$ 값을 얻는 데&lt;br /&gt;
이를 $\hat{y}$로써 표현한다.&lt;/p&gt;

&lt;p&gt;위에서 만들어진 식으로부터 $w$를 추출한다.&lt;/p&gt;

&lt;p&gt;첫 번째 식에서 추출한 $w$ 값을&lt;br /&gt;
$w$ 행렬의 첫 번째 행으로 담고,&lt;/p&gt;

&lt;p&gt;두 번째 식에서 추출한 $w$ 값을&lt;br /&gt;
$w$ 행렬의 두 번째 행 으로 담고,&lt;/p&gt;

&lt;p&gt;첫 번째 식에서 추출한 $w$ 값을&lt;br /&gt;
$w$ 행렬의 세 번째 행으로 담는다.&lt;/p&gt;

&lt;p&gt;두 개의 행렬이 만들어지면,&lt;br /&gt;
$W \cdot X $와 같이 행렬 곱셈을 이용한다.&lt;/p&gt;

&lt;p&gt;계산을 진행하면, 각각 $A, B, C$을 분류하는 $y$값이 구해진다.&lt;/p&gt;

&lt;p&gt;즉, 이항 분류를 통해 각 값을 분류할 수 있는 $\hat{y}$을 찾을 수 있다.&lt;br /&gt;
또한, 결과 값을 행렬로 표현하면,&lt;br /&gt;
$H(X) = WX$로 이전에 설정한 가설로써 표현 할 수 있다.&lt;/p&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="AI" /><summary type="html">본 글은 모두를 위한 머신러닝/딥러닝 강의를 참고하여 작성하였습니다.</summary></entry><entry><title type="html">Logistic(Regression) Classification TensorFlow 구현</title><link href="https://hodurie.github.io/study/ai/ML_Lab_05" rel="alternate" type="text/html" title="Logistic(Regression) Classification TensorFlow 구현" /><published>2020-05-20T00:00:00+09:00</published><updated>2020-05-20T00:00:00+09:00</updated><id>https://hodurie.github.io/study/ai/ML-Lab-05</id><content type="html" xml:base="https://hodurie.github.io/study/ai/ML_Lab_05">&lt;p&gt;본 글은 &lt;a href=&quot;https://hunkim.github.io/ml/&quot;&gt;모두를 위한 머신러닝/딥러닝 강의&lt;/a&gt;를 참고하여 작성하였습니다.&lt;br /&gt;
소스 코드는 &lt;a href=&quot;https://github.com/hunkim/DeepLearningZeroToAll&quot;&gt;DeepLearningZeroToAll&lt;/a&gt;를 참고 하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;ml-lab-05-tensorflow로-logistic-classification의-구현하기&quot;&gt;ML lab 05: TensorFlow로 Logistic Classification의 구현하기&lt;/h1&gt;
&lt;p&gt;지난 시간에 다뤘던 로지스틱 회귀의 가정과 비용함수에 대해 다뤄보기로 하겠습니다.&lt;/p&gt;

&lt;p&gt;아래 식은 가정과 비용함수 입니다.&lt;/p&gt;

\[H(X) = \frac{1}{1+e^{-W^TX} }\]

\[\text{cost}(W) = 
-\frac{1}{m}\sum ylog(H(x)) + (1-y)log(1-H(x))\]

\[W := W - \alpha \frac{\partial}{\partial{W} }\]

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tensorflow&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;training-data&quot;&gt;Training Data&lt;/h2&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;x_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sequential&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Dense&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;units&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_dim&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Activation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'sigmoid'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;$ H(X) $의 부분이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sigmoid&lt;/code&gt;의 형태이므로,&lt;br /&gt;
활성화 함수 부분에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sigmoid&lt;/code&gt;를 넣어준다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'binary_crossentropy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;optimizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;optimizers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SGD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;metrics&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'accuracy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;summary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Model: &quot;sequential&quot;
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense (Dense)                (None, 1)                 3         
_________________________________________________________________
activation (Activation)      (None, 1)                 0         
=================================================================
Total params: 3
Trainable params: 3
Non-trainable params: 0
_________________________________________________________________
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;history&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;epochs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Accuracy: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;history&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;history&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'accuracy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Accuracy:  1.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="AI" /><summary type="html">본 글은 모두를 위한 머신러닝/딥러닝 강의를 참고하여 작성하였습니다. 소스 코드는 DeepLearningZeroToAll를 참고 하여 작성하였습니다.</summary></entry><entry><title type="html">Logistic(Regression) Classification 02</title><link href="https://hodurie.github.io/study/ai/ML_Lec_05_01" rel="alternate" type="text/html" title="Logistic(Regression) Classification 02" /><published>2020-05-19T00:00:00+09:00</published><updated>2020-05-19T00:00:00+09:00</updated><id>https://hodurie.github.io/study/ai/ML-Lec-05-02</id><content type="html" xml:base="https://hodurie.github.io/study/ai/ML_Lec_05_01">&lt;p&gt;본 글은 &lt;a href=&quot;https://hunkim.github.io/ml/&quot;&gt;모두를 위한 머신러닝/딥러닝 강의&lt;/a&gt;를 참고하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;ml-lec-5-2-logistic-regression의-cost-함수-설명&quot;&gt;ML lec 5-2 Logistic Regression의 cost 함수 설명&lt;/h1&gt;
&lt;h2 id=&quot;linear-cost-function&quot;&gt;Linear Cost Function&lt;/h2&gt;
&lt;p&gt;먼저, 이전 글에서 설명한&lt;br /&gt;
로지스틱 회귀의 가설은&lt;/p&gt;

\[H(X) = \frac{1}{1+e^{-W^TX} }\]

&lt;p&gt;이다.&lt;/p&gt;

&lt;p&gt;이는 $y$의 값을 0과 1사이의 값으로 변환 시켜주는 식이다.&lt;/p&gt;

&lt;p&gt;이때, 우리가 $W$를 $x$축에 두고,&lt;br /&gt;
선형 회귀식의 $Cost(W)$을 $y$축에 두면&lt;br /&gt;
약과의 겉 테두리 부분처럼&lt;br /&gt;
각 지점에 굴곡이 있는 아래로 볼록한 그래프가 만들어진다.&lt;/p&gt;

&lt;p&gt;이를 이용해서 Gradient Descent 기법을 사용하게되면,&lt;br /&gt;
시작점이 어디냐에 따라 최적의 값이 달라지게 된다.&lt;/p&gt;

&lt;p&gt;이를 방지하고자,&lt;br /&gt;
우리는 비용함수를 새롭게 정의해야 한다.&lt;/p&gt;

&lt;h2 id=&quot;logistic-cost-function&quot;&gt;Logistic Cost Function&lt;/h2&gt;
&lt;p&gt;\(\mathbf{cost}(W) = \frac{1}{m}\sum \mathbf{c}(H(x), y)\)&lt;/p&gt;

\[\text{c}(H(x),y) = 
\begin{cases}
-log(H(x)) &amp;amp; y = 1\\
-log(1-H(x)) &amp;amp; y = 0
\end{cases}\]

&lt;p&gt;첫 번째로,&lt;br /&gt;
가설에 사용된 $e$에 대응되는 값이&lt;br /&gt;
$log$ 값이라는 점&lt;/p&gt;

&lt;p&gt;두 번째로,&lt;br /&gt;
$g(z) = -log(z)$가 있다고 가정할 시,&lt;br /&gt;
$z$의 값이 거의 동일하면 $g(z)$는 0의 가까운 값을 갖고&lt;br /&gt;
$z$의 값이 일치하지 않으면 $g(z)$는 무한대에 가까운 값은 갖는 점&lt;/p&gt;

&lt;h2 id=&quot;cost-function-재표현&quot;&gt;Cost Function 재표현&lt;/h2&gt;
&lt;p&gt;위와 같은 식으로 표현했을 때,&lt;br /&gt;
식이 복잡하게 느껴질 수 있다.&lt;/p&gt;

&lt;p&gt;이를 간편하게 하나의 식으로 줄일 수 있다.&lt;/p&gt;

\[\text{c}(H(x),y) = 
-ylog(H(x)) - (1-y)log(1-H(x))\]

&lt;p&gt;$y$의 값에 1을 넣게 되면,&lt;br /&gt;
뒤의 식이 사라져&lt;br /&gt;
$-log(H(x))$의 식만 살아나고&lt;/p&gt;

&lt;p&gt;$y$의 값에 0을 넣게 되면,&lt;br /&gt;
앞의 식이 사라져&lt;br /&gt;
$-log(1- H(x))$의 식만 살아난다.&lt;/p&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="AI" /><summary type="html">본 글은 모두를 위한 머신러닝/딥러닝 강의를 참고하여 작성하였습니다.</summary></entry><entry><title type="html">쉽게 배우는 Java 알고리즘 입문</title><link href="https://hodurie.github.io/study/java/algorithm" rel="alternate" type="text/html" title="쉽게 배우는 Java 알고리즘 입문" /><published>2020-05-18T00:00:00+09:00</published><updated>2020-05-18T00:00:00+09:00</updated><id>https://hodurie.github.io/study/java/Java-Algorithm</id><content type="html" xml:base="https://hodurie.github.io/study/java/algorithm">&lt;p&gt;본 글은 &lt;strong&gt;쉽게 배우는 Java 알고리즘 입문&lt;/strong&gt; 강의를 바탕으로 작성하였습니다.&lt;br /&gt;
소스 코드는 &lt;a href=&quot;https://github.com/VisualAcademy&quot;&gt;VisualAcademy&lt;/a&gt;를 참고 하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;알고리즘algorithm과-절차-지향-프로그래밍&quot;&gt;알고리즘(Algorithm)과 절차 지향 프로그래밍&lt;/h1&gt;
&lt;h2 id=&quot;알고리즘&quot;&gt;알고리즘&lt;/h2&gt;
&lt;p&gt;프로그램의 가장 작은 단위는&lt;br /&gt;
세 개의 단계를 거친다.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;입력 : 자료 구조에 담당하는 영역&lt;/li&gt;
  &lt;li&gt;처리 : 알고리즘 처리 영역&lt;/li&gt;
  &lt;li&gt;출력 - UI가 담당하는 영역&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;여기서 우리가 다룰 부분은 처리 부분이다.&lt;/p&gt;

&lt;p&gt;그렇다면, 알고리즘이란 무엇일까?&lt;/p&gt;

&lt;p&gt;알고리즘이란,&lt;br /&gt;
프로그램 개발에 있어서 필요한 문제를 해결하는 방법을 체계적으로 정리하는 방법&lt;br /&gt;
즉, &lt;strong&gt;문제 해결 능력&lt;/strong&gt; 이다.&lt;/p&gt;

&lt;p&gt;강의 에서 다룰 알고리즘&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;합계 알고리즘&lt;/li&gt;
  &lt;li&gt;개수 알고리즘&lt;/li&gt;
  &lt;li&gt;평균 알고리즘&lt;/li&gt;
  &lt;li&gt;최댓값 알고리즘&lt;/li&gt;
  &lt;li&gt;최솟값 알고리즘&lt;/li&gt;
  &lt;li&gt;근삿값 알고리즘&lt;/li&gt;
  &lt;li&gt;순위 알고리즘&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;정렬 알고리즘&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;검색 알고리즘&lt;/li&gt;
  &lt;li&gt;병합 알고리즘&lt;/li&gt;
  &lt;li&gt;최빈값 알고리즘&lt;/li&gt;
  &lt;li&gt;그룹 알고리즘&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="Java" /><category term="Algorithm" /><summary type="html">본 글은 쉽게 배우는 Java 알고리즘 입문 강의를 바탕으로 작성하였습니다. 소스 코드는 VisualAcademy를 참고 하여 작성하였습니다.</summary></entry><entry><title type="html">Logistic(Regression) Classification 01</title><link href="https://hodurie.github.io/study/ai/ML_Lec_05_02" rel="alternate" type="text/html" title="Logistic(Regression) Classification 01" /><published>2020-05-16T00:00:00+09:00</published><updated>2020-05-16T00:00:00+09:00</updated><id>https://hodurie.github.io/study/ai/ML-Lec-05-01</id><content type="html" xml:base="https://hodurie.github.io/study/ai/ML_Lec_05_02">&lt;p&gt;본 글은 &lt;a href=&quot;https://hunkim.github.io/ml/&quot;&gt;모두를 위한 머신러닝/딥러닝 강의&lt;/a&gt;를 참고하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;ml-lec-5-1-logistic-classification의-가설-함수-정의&quot;&gt;ML lec 5-1: Logistic Classification의 가설 함수 정의&lt;/h1&gt;
&lt;h2 id=&quot;regression&quot;&gt;Regression&lt;/h2&gt;
&lt;p&gt;Regression에서는 우리는 세 가지 가정을 한다.&lt;br /&gt;
첫 번째, 가정이다.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;이 데이터는 선형적인 관계가 존재할 것인가?&lt;/li&gt;
  &lt;li&gt;다변수를 가지지고 있는 선형회귀 식이 존재할 것이다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;두 번째, Cost Function&lt;br /&gt;
주어진 가설을 바탕으로,&lt;br /&gt;
각각의 비용값들 계산&lt;/p&gt;

&lt;p&gt;세 번째, Gradient Decent&lt;br /&gt;
위의 식을 바탕으로,&lt;br /&gt;
값을 최소화 시키는 $W$ 찾기&lt;/p&gt;

&lt;h2 id=&quot;classification&quot;&gt;Classification&lt;/h2&gt;
&lt;p&gt;데이터를 특정 기준에 따라 분류하는 것&lt;/p&gt;

&lt;p&gt;사용예,&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;스팸메일 분류(일반 메일 또는 스팸 메일)&lt;/li&gt;
  &lt;li&gt;시험 합격 여부(합격 또는 불합격)&lt;/li&gt;
  &lt;li&gt;암 종양 여부(음성 또는 양성)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;이 장에서 다룰 내용은 &lt;br /&gt;
0과 1의 값을 갖는  &lt;br /&gt;
&lt;strong&gt;Binary Classification&lt;/strong&gt;이다.&lt;/p&gt;

&lt;p&gt;이때, 우리가 값을 분류하기 위해&lt;br /&gt;
선형 식을 이용한다고 해보자.&lt;/p&gt;

&lt;p&gt;우리가 생각 할 수 있는 최선의 방법은&lt;br /&gt;
$y$ 값이 0.5 되는 지점과&lt;br /&gt;
기울기가 만나는 지점을 기점으로&lt;br /&gt;
$x$ 값을 나누는 것이다.&lt;/p&gt;

&lt;p&gt;하지만, 여기서 문제가 발생한다.&lt;br /&gt;
기울기에 따라 0의 값이 1의 값으로 분류 될 수 있고,&lt;br /&gt;
반대의 경우도 생길 수 있다.&lt;/p&gt;

&lt;p&gt;이런 문제점을 보완하고자 나온것이&lt;br /&gt;
&lt;strong&gt;Logistic Regression&lt;/strong&gt; 이다.&lt;/p&gt;

&lt;h2 id=&quot;logistic-hypothesis&quot;&gt;Logistic Hypothesis&lt;/h2&gt;
&lt;p&gt;\(H(X) = \frac{1}{1 + e^{-W^TX} }\)&lt;/p&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="AI" /><summary type="html">본 글은 모두를 위한 머신러닝/딥러닝 강의를 참고하여 작성하였습니다.</summary></entry><entry><title type="html">파일 데이터 로딩</title><link href="https://hodurie.github.io/study/ai/ML_Lab_04_02" rel="alternate" type="text/html" title="파일 데이터 로딩" /><published>2020-05-15T00:00:00+09:00</published><updated>2020-05-15T00:00:00+09:00</updated><id>https://hodurie.github.io/study/ai/ML-Lab-04-02</id><content type="html" xml:base="https://hodurie.github.io/study/ai/ML_Lab_04_02">&lt;p&gt;본 글은 &lt;a href=&quot;https://hunkim.github.io/ml/&quot;&gt;모두를 위한 머신러닝/딥러닝 강의&lt;/a&gt;를 참고하여 작성하였습니다.&lt;br /&gt;
소스 코드는 &lt;a href=&quot;https://github.com/hunkim/DeepLearningZeroToAll&quot;&gt;DeepLearningZeroToAll&lt;/a&gt;를 참고 하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;ml-lab-04-2-tensorflow로-파일에서-데이터-읽어오기&quot;&gt;ML lab 04-2: TensorFlow로 파일에서 데이터 읽어오기&lt;/h1&gt;
&lt;p&gt;이번 시간에는 로컬상에 저장 돼 있는 파일을 읽는 방법에 대해 알아보겠습니다.&lt;/p&gt;

&lt;p&gt;사용할 데이터는 &lt;a href=&quot;https://github.com/hunkim/DeepLearningZeroToAll&quot;&gt;data-01-test-score.csv&lt;/a&gt;입니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tensorflow&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;xy&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loadtxt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'data-01-test-score.csv'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;delimiter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;','&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;파일의 형식에 따라 데이터를 다르게 구분합니다.&lt;br /&gt;
오늘 쓰일 데이터는 csv파일로 값의 구분을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;,&lt;/code&gt;을 통해 이뤄집니다.&lt;br /&gt;
이때, 어떤 구분자를 이용해 구분할 것인지를 정해주는 것이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;delimiter&lt;/code&gt; 입니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;x_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;x_data shape:&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;y_data shape:&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[[ 73.  80.  75.]
 [ 93.  88.  93.]
 [ 89.  91.  90.]
 [ 96.  98. 100.]
 [ 73.  66.  70.]
 [ 53.  46.  55.]
 [ 69.  74.  77.]
 [ 47.  56.  60.]
 [ 87.  79.  90.]
 [ 79.  70.  88.]
 [ 69.  70.  73.]
 [ 70.  65.  74.]
 [ 93.  95.  91.]
 [ 79.  80.  73.]
 [ 70.  73.  78.]
 [ 93.  89.  96.]
 [ 78.  75.  68.]
 [ 81.  90.  93.]
 [ 88.  92.  86.]
 [ 78.  83.  77.]
 [ 82.  86.  90.]
 [ 86.  82.  89.]
 [ 78.  83.  85.]
 [ 76.  83.  71.]
 [ 96.  93.  95.]] 
x_data shape: (25, 3)
[[152.]
 [185.]
 [180.]
 [196.]
 [142.]
 [101.]
 [149.]
 [115.]
 [175.]
 [164.]
 [141.]
 [141.]
 [184.]
 [152.]
 [148.]
 [192.]
 [147.]
 [183.]
 [177.]
 [159.]
 [177.]
 [175.]
 [175.]
 [149.]
 [192.]] 
y_data shape: (25, 1)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sequential&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Dense&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;units&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_dim&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;activation&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'linear'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;summary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Model: &quot;sequential&quot;
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense (Dense)                (None, 1)                 4         
=================================================================
Total params: 4
Trainable params: 4
Non-trainable params: 0
_________________________________________________________________
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'mse'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;optimizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;optimizers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SGD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1e-5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;history&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;epochs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Your score will be &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;70&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;101&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]))&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Other scores will be &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;70&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;110&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;90&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Your score will be  [[185.7961]]
Other scores will be  [[186.12904]
 [174.52814]]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="AI" /><summary type="html">본 글은 모두를 위한 머신러닝/딥러닝 강의를 참고하여 작성하였습니다. 소스 코드는 DeepLearningZeroToAll를 참고 하여 작성하였습니다.</summary></entry><entry><title type="html">여러개의 입력(feature)의 Linear Regression TensorFlow 구현</title><link href="https://hodurie.github.io/study/ai/ML_Lab_04_01" rel="alternate" type="text/html" title="여러개의 입력(feature)의 Linear Regression TensorFlow 구현" /><published>2020-05-14T00:00:00+09:00</published><updated>2020-05-14T00:00:00+09:00</updated><id>https://hodurie.github.io/study/ai/ML-lab-04-01</id><content type="html" xml:base="https://hodurie.github.io/study/ai/ML_Lab_04_01">&lt;p&gt;본 글은 &lt;a href=&quot;https://hunkim.github.io/ml/&quot;&gt;모두를 위한 머신러닝/딥러닝 강의&lt;/a&gt;를 참고하여 작성하였습니다.&lt;br /&gt;
소스 코드는 &lt;a href=&quot;https://github.com/hunkim/DeepLearningZeroToAll&quot;&gt;DeepLearningZeroToAll&lt;/a&gt;를 참고 하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;ml-lab-04-1-multi-variable-linear-regression을-tensorflow에서-구현하기&quot;&gt;ML lab 04-1: multi-variable linear regression을 TensorFlow에서 구현하기&lt;/h1&gt;
&lt;h2 id=&quot;hypothesis-using-matrix&quot;&gt;Hypothesis using matrix&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://hodurie.github.io/study/ai/ML_Lec_04&quot;&gt;여러개의 입력(feature)의 Linear Regression&lt;/a&gt;에서 다루었던 내용을 TensorFlow로 구현해 보겠습니다.&lt;/p&gt;

&lt;p&gt;$x$ 변수의 개수를 세 개를 기준&lt;br /&gt;
여기서 사용할 가설과 수식은&lt;/p&gt;

\[H(x_1, x_2, x_3) = w_1x_1 + w_2x_2 + w_3x_3 + b\]

\[\mathbf{cost}(W, b) = { {1} \over {m} }\sum_{i = 1}^m(H(x_{1i}, x_{2i}, x_{3i}) - y_i)^2\]

&lt;p&gt;이와 같습니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tensorflow&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;x_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;73.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;80.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;75.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;93.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;88.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;93.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;89.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;91.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;90.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;96.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;98.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;100.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;73.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;66.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;70.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;152.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;185.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;180.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;196.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;142.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;$X$는 5행 3열로, &lt;br /&gt;
5개의 값을 갖고 있는 세 개의 $x$로 구성 돼 있습니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sequential&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Dense&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;units&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_dim&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Activation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'linear'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;모델의 경우 3개의 값을 입력받고&lt;br /&gt;
하나의 값을 출력하는 것인데&lt;br /&gt;
여기서의 의미는&lt;br /&gt;
길이가 5인 $x$ 벡터 세 개를 넣어&lt;br /&gt;
길이가 5인 $y$ 벡터를 하나 출력한다&lt;br /&gt;
입니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'mse'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;optimizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;keras&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;optimizers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SGD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1e-5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;summary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Model: &quot;sequential&quot;
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense (Dense)                (None, 1)                 4         
_________________________________________________________________
activation (Activation)      (None, 1)                 0         
=================================================================
Total params: 4
Trainable params: 4
Non-trainable params: 0
_________________________________________________________________
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;history&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;epochs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;y_predict&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;72.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;93.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;90.&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]))&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[[165.74065]]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="AI" /><summary type="html">본 글은 모두를 위한 머신러닝/딥러닝 강의를 참고하여 작성하였습니다. 소스 코드는 DeepLearningZeroToAll를 참고 하여 작성하였습니다.</summary></entry><entry><title type="html">여러개의 입력(feature)의 Linear Regression</title><link href="https://hodurie.github.io/study/ai/ML_Lec_04" rel="alternate" type="text/html" title="여러개의 입력(feature)의 Linear Regression" /><published>2020-05-13T00:00:00+09:00</published><updated>2020-05-13T00:00:00+09:00</updated><id>https://hodurie.github.io/study/ai/ML-Lec-04</id><content type="html" xml:base="https://hodurie.github.io/study/ai/ML_Lec_04">&lt;p&gt;본 글은 &lt;a href=&quot;https://hunkim.github.io/ml/&quot;&gt;모두를 위한 머신러닝/딥러닝 강의&lt;/a&gt;를 참고하여 작성하였습니다.&lt;/p&gt;

&lt;h1 id=&quot;ml-lec-04---multi-variable-linear-regression&quot;&gt;ML lec 04 - multi-variable linear regression&lt;/h1&gt;
&lt;p&gt;지난 시간에는 변수가 하나인 선형회귀식에 대해 알아봤습니다.&lt;br /&gt;
오늘은 변수의 개수가 두 개 이상인 선형회귀식에 대해 알아보겠습니다.&lt;/p&gt;

&lt;h2 id=&quot;multi-variable-linear-regression&quot;&gt;Multi-Variable Linear Regression&lt;/h2&gt;
&lt;p&gt;위에서 언급했다시피 식을 이용해 $y$ 값을 예측할 때,&lt;br /&gt;
하나의 값이 아닌 여러 개의 값을 사용합니다.&lt;/p&gt;

&lt;p&gt;여러 개의 값을 사용한다면,&lt;br /&gt;
이전에 설정했던 가설과 비용함수도 달라질까요?&lt;br /&gt;
질문의 답은 그렇다 입니다.&lt;/p&gt;

&lt;p&gt;그렇다면, 변수의 개수에 따라 어떻게 변화했는지 알아보도록 하겠습니다.&lt;br /&gt;
먼저, $x$의 개수가 세 개라고 정한 후 진행하도록 하겠습니다.&lt;/p&gt;

&lt;p&gt;기존 단순 선형회귀의 경우&lt;/p&gt;

\[H(x) = Wx + b\]

&lt;p&gt;와 같이 표현했습니다.&lt;br /&gt;
하지만, 다중 선형회귀(다변수 선형회귀)는 $x$의 값이 많으므로,&lt;br /&gt;
$x$들에 대한 $w$를 따로따로 표현해 줘야 합니다.&lt;/p&gt;

\[H(x_1, x_2, x_3) = w_1x_1 + w_2x_2 + w_3x_3 + b\]

&lt;p&gt;비용함수의 경우에도 달라진 $x$에 대해서 다르게 표현해 줘야 합니다.&lt;/p&gt;

\[\mathbf{cost}(W, b) = { {1} \over {m} }\sum_{i = 1}^m(H(x_{1i}, x_{2i}, x_{3i}) - y_i)^2\]

&lt;p&gt;만약, $x$의 값이 세 개가 아닌 열 개, 백 개와 같이 많은 값을 갖게 된다면,&lt;br /&gt;
우리는 이를 표현하기가 매우 불편합니다.&lt;/p&gt;

&lt;p&gt;이를 간단하게 표현할 수 있게 해주는 것이 바로&lt;br /&gt;
&lt;strong&gt;Matrix&lt;/strong&gt; 입니다.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Matrix&lt;/strong&gt;를 이용하면, 우리는 위의 식을 간단하게 표현할 수 있습니다.&lt;br /&gt;
가설의 식들은 $x$와 $w$의 곱으로 이루어져 있습니다.&lt;br /&gt;
이를 따로 분리해서 생각해보면&lt;br /&gt;
$x$ 벡터와 $w$벡터의 곱으로서 나타낼 수 있습니다.&lt;/p&gt;

&lt;p&gt;두 개의 식을 곱해서 나타낸 &lt;strong&gt;Matrix&lt;/strong&gt;로 식을 표현하면&lt;/p&gt;

\[H(x) = XW\]

&lt;p&gt;와 같이 표현 할 수 있습니다.&lt;/p&gt;

&lt;p&gt;이를 일반화 하면, 여러 $x$의 값을 가진 행렬과&lt;br /&gt;
$w$ 벡터의 곱으로 이를 표현 할 수 있습니다.&lt;/p&gt;

&lt;p&gt;하지만, 여기서 주의할 점이 하나 있습니다.&lt;br /&gt;
바로 행렬들의 차원을 고려해 줘야 된다는 점입니다.&lt;br /&gt;
행렬의 곱은 행 곱하기 열을 통해 나타내며,&lt;br /&gt;
두 개의 행렬 중 앞 행렬의 열과 뒤 행렬의 행의 차원이 같아야 합니다.&lt;/p&gt;

&lt;p&gt;예를들어,&lt;br /&gt;
$A$는 3행 4열 행열,  &lt;br /&gt;
$B$는 4행 1열 행렬(벡터)&lt;br /&gt;
일 때, $A \cdot B$는 가능하지만, $B \cdot A$는 불가능 합니다.&lt;/p&gt;

&lt;p&gt;또한, 곱이후에 만들어 지는 행렬은 앞 행렬의 행의 뒤 행렬의 열의 차원으로 만들어집니다.&lt;br /&gt;
위의 예를 갖고 말하면,&lt;br /&gt;
$A \cdot B$는 3행 1열의 행렬이 만들어 집니다.&lt;/p&gt;</content><author><name>Hodurie</name></author><category term="[&quot;STUDY - etc&quot;]" /><category term="AI" /><summary type="html">본 글은 모두를 위한 머신러닝/딥러닝 강의를 참고하여 작성하였습니다.</summary></entry></feed>