[GoogleML] Logistic Regression as a Neural Network

2023. 9. 5. 21:47ใ†ArtificialIntelligence/2023GoogleMLBootcamp

 

 

 

 

 

 

about ํ–‰๋ ฌ ํ‘œ๊ธฐ

 

 

 

์™œ ์‹œ๊ทธ๋ชจ์ด๋“œ๋ฅผ ์ทจํ• ๊นŒ? (0~1 ์‚ฌ์ด๋กœ ์ œํ•œ)

 

 

 

X0 = 1 ์ด notation์€ ์—ฌ๊ธฐ์„œ๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค

 

W๊ฐ€ only parameter, nx dim vector.

b๋Š” real number 

 

 

 

loss func - single training example์— ๋Œ€ํ•œ error

cost func - cost of your params (์ „์ฒด ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•ด, Parameter W, b์˜ ํ‰๊ท  ์—๋Ÿฌ๋ฅผ ์˜๋ฏธ) 

 

 

 

 

Gradient Descent 

 

 

 

slope์˜ ๊ธฐ์šธ๊ธฐ๊ฐ€ gradient

 

 

 

ํŽธ๋ฏธ๋ถ„์ด๋ผ๋ฉด partial / J๊ฐ€ ๋‹จ์ผ ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ํ•จ์ˆ˜๋ผ๋ฉด d๋ฅผ ์จ๋„ okay

slope of the function

 

 

 

Derivatives

a๋ฅผ ์กฐ๊ธˆ ์ฆ๊ฐ€์‹œ์ผฐ์„ ๋•Œ, ์–ผ๋งŒํผ ํ•จ์ˆ˜๊ฐ’์ด F(a)๊ฐ€ ์ฆ๊ฐ€ํ•˜๋Š”๊ฐ€? ์˜ ๊ด€์ 

์ง์„ ์ด๋ผ๋ฉด (1์ฐจ ํ•จ์ˆ˜)

a์˜ ๊ฐ’์— ๋ฌด๊ด€ํ•˜๊ฒŒ, ํ•จ์ˆ˜์˜ ์ฆ๊ฐ€๋Ÿ‰์€ ๋ณ€์ˆ˜ ์ฆ๊ฐ€๋Ÿ‰์˜ 3๋ฐฐ 

์ฆ‰ 3์œผ๋กœ ๋ฏธ๋ถ„๊ฐ’์ด ์ผ์ •ํ•˜๋‹ค

 

 

 

2์ฐจ ํ•จ์ˆ˜์—์„œ๋Š” ๊ธฐ์šธ๊ธฐ ๊ฐ’์ด a point์— ๋”ฐ๋ผ ๋ณ€ํ•œ๋‹ค!

 

 

 

๋‹ค์–‘ํ•œ ๊ธฐ์šธ๊ธฐ์˜ ๋„ํ•จ์ˆ˜๋“ค

 

 

 

Computation Graph

for backpropagation

 

 

 

Derivatives with a Computation Graph

 

 

 

chain rule

 

 

 

์ฝ”๋“œ ๊ตฌํ˜„ ์‹œ, da, dv ์‚ฌ์šฉ

 

 

 

์ˆœ์ฐจ์ ์œผ๋กœ chain rule์„ ์ ์šฉํ•˜์—ฌ J์— ์ž‘์šฉํ•˜๋Š” ๊ธฐ์šธ๊ธฐ๋ฅผ ๊ณ„์‚ฐํ•œ๋‹ค.

 

 

 

Logistic Regression Gradient Descent

loss๋ฅผ ์ตœ์†Œํ™”ํ•˜๊ธฐ ์œ„ํ•œ w1, w2๋ฅผ ์ฐพ์•„๋ผ

 

 

 

dvar ํ‘œ๊ธฐ์— ๋Œ€ํ•œ ์„ค๋ช… => var๊ฐ€ ๊ฒฐ๊ณผ์— ๋ฏธ์น˜๋Š” ์˜ํ–ฅ๋ ฅ ์˜๋ฏธ (ํŽธ๋ฏธ๋ถ„ ๊ฐ’)

 

 

 

์‹œ๊ทธ๋ชจ์ด๋“œ ๋ฏธ๋ถ„ ์ˆ˜์‹

 

 

 

ํŠน์ • wi์— ๋Œ€ํ•œ ๋ฏธ๋ถ„์€ input i๊ฐ€ ํŠ€์–ด๋‚˜์™€์„œ!

 

 

 

Gradient Descent on m Examples

 

 

 

ํ•˜๋‚˜์˜ ๊ฐ’์„ ๊ณ„์‚ฐํ•˜๊ธฐ ์œ„ํ•ด์„œ ์œ„์˜ ๊ณผ์ •์„ ๋ฐ˜๋ณตํ•˜๋Š” ๊ฒƒ์ด ๋ณต์žกํ•˜๋‹ค -> vectorization (ํ–‰๋ ฌ ์—ฐ์‚ฐ?)

ํฐ data์— ๋Œ€ํ•ด ๋งค์šฐ ํšจ์œจ์ ์œผ๋กœ ๊ณ„์‚ฐ ๊ฐ€๋Šฅ! :) 

 

 

 

 

 

Quiz ํƒˆ ๋ฝ ๐Ÿ”ฅ

ํ•˜ ํ•˜ํ•ณ

 

 

 

^^_ ์ •์‹  ๋˜‘๋ฐ”๋กœ ์ฐจ๋ฆฌ๊ณ  ํ’€์ž . .