๐ŸŒ Jero's Wiki

๐Ÿง Problems์™ธ๊ณผ์˜์‚ฌ ๋จธ์“ฑ์ด๋Š” ์‘๊ธ‰์‹ค์— ์˜จ ํ™˜์ž์˜ ์‘๊ธ‰๋„๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ง„๋ฃŒ ์ˆœ์„œ๋ฅผ ์ •ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์ •์ˆ˜ ๋ฐฐ์—ด ``emergency``๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ ์‘๊ธ‰๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ์ง„๋ฃŒ ์ˆœ์„œ๋ฅผ ์ •ํ•œ ๋ฐฐ์—ด์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. ๐Ÿ’ก Solutionsfunction solution(emergency) { const descending = [...emergency].sort((a, b) => b - a); return emergency.map(value => descending.indexOf(value) + 1);}์ฝ”๋“œ ์„ค๋ช…``sort( )`` ๋ฉ”์„œ๋“œ๋ฅผ ํ™œ์šฉํ•ด ๋ฐฐ์—ด ์š”์†Œ๋ฅผ ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•ด์ค๋‹ˆ๋‹ค. ์ด๋•Œ, ๋ฐฐ์—ด์— ๋ฐ”๋กœ ``sort( )``๋ฅผ ์ ์šฉํ•˜๋ฉด ์›..
๐Ÿง Problems์ตœ๋นˆ๊ฐ’์€ ์ฃผ์–ด์ง„ ๊ฐ’ ์ค‘์—์„œ ๊ฐ€์žฅ ์ž์ฃผ ๋‚˜์˜ค๋Š” ๊ฐ’์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์ •์ˆ˜ ๋ฐฐ์—ด ``array``๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, ์ตœ๋นˆ๊ฐ’์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. ์ตœ๋นˆ๊ฐ’์ด ์—ฌ๋Ÿฌ ๊ฐœ๋ฉด -1์„ return ํ•ฉ๋‹ˆ๋‹ค. ๐Ÿ’ก Solutionsconst solution = (array) => { const frequency = {}; array.forEach(num => { frequency[num] = (frequency[num] || 0) + 1; }); const maxFreq = Math.max(...Object.values(frequency)); const modes = Object.keys(frequency).f..
๐Ÿง Problems์ฒซ ๋ฒˆ์งธ ๋ถ„์ˆ˜์˜ ๋ถ„์ž์™€ ๋ถ„๋ชจ๋ฅผ ๋œปํ•˜๋Š” ``numer1``, ``denom1``, ๋‘ ๋ฒˆ์งธ ๋ถ„์ˆ˜์˜ ๋ถ„์ž์™€ ๋ถ„๋ชจ๋ฅผ ๋œปํ•˜๋Š” ``numer2``, ``denom2``๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. ๋‘ ๋ถ„์ˆ˜๋ฅผ ๋”ํ•œ ๊ฐ’์„ ๊ธฐ์•ฝ ๋ถ„์ˆ˜๋กœ ๋‚˜ํƒ€๋ƒˆ์„ ๋•Œ ๋ถ„์ž์™€ ๋ถ„๋ชจ๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ๋‹ด์€ ๋ฐฐ์—ด์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. ๐Ÿ’ก Solutionsconst gcd = (num1, num2) => num2 === 0 ? num1 : gcd(num2, num1 % num2);const solution = (numer1, denom1, numer2, denom2) => { const numer = numer1 * denom2 + numer2 * denom1; const denom =..
Weight Initialization๋”ฅ๋Ÿฌ๋‹ ๋ชจ๋ธ์„ ํ•™์Šตํ•œ๋‹ค๋Š” ๊ฑด loss ๊ฐ’์ด ์ตœ์†Œ๊ฐ€ ๋˜๋Š” parameter๋ฅผ ์ฐพ๋Š” ๊ฒƒ์ด๋‹ค. ์ตœ์ ์˜ parameter๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•ด ๊ณ ๋ คํ•ด์•ผ ํ•  ์ ๋“ค์ด ์—ฌ๋Ÿฟ ์žˆ์ง€๋งŒ, ๊ทธ ์ค‘ parameter์˜ ์ดˆ๊ธฐ๊ฐ’ ์„ค์ •์€ ์ค‘์š”ํ•œ ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค. ์ด ๊ธ€์—์„  parameter ์ฆ‰, weight์˜ ์ดˆ๊ธฐ๊ฐ’์„ ์„ค์ •ํ•˜๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋‹ค๋ค„๋ณด๋ ค ํ•œ๋‹ค. Zero Initialization (or Same Initialization)weight ํฌ๊ธฐ๋ฅผ ํฌ๊ฒŒ ๋ถ€์—ฌํ• ์ˆ˜๋ก ๋ชจ๋ธ์€ ํŠน์ • ๋ฐ์ดํ„ฐ์—๋งŒ ์ž˜ ๋งž๋Š” overfitting ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๊ธฐ ์‰ฝ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— weight์„ 0 ํ˜น์€ ๊ต‰์žฅํžˆ ์ž‘์€ ๊ฐ’์œผ๋กœ ๋ถ€์—ฌํ•ด ํ•™์Šต์„ ์ง„ํ–‰์‹œ์ผœ๋ณด์ž.      $h_1 = h_2 = h_3 = \mathbf{W}(i_..
Regularization ๋”ฅ๋Ÿฌ๋‹ ๋ชจ๋ธ์„ ํ•™์Šตํ•˜๋Š” ๊ณผ์ •์—์„œ ํ•ด๋‹น ๋ชจ๋ธ์ด ํ•™์Šต ๋ฐ์ดํ„ฐ์—๋งŒ ์ตœ์ ํ™”๋˜๋ฉด ์–ด๋–จ๊นŒ? ์•„๋งˆ ์ƒˆ๋กœ์šด ๋ฐ์ดํ„ฐ๊ฐ€ ์ž…๋ ฅ๋˜๋ฉด ๋ชจ๋ธ์€ ์ œ๋Œ€๋กœ ๋œ ์˜ˆ์ธก๊ฐ’์„ ์ถœ๋ ฅํ•˜์ง€ ๋ชปํ•  ๊ฒƒ์ด๋‹ค. ์ด๋Ÿฐ ๋ฌธ์ œ๋ฅผ Overfitting(๊ณผ์ ํ•ฉ)์ด๋ผ ํ•œ๋‹ค. ์ด๋Ÿฐ Overfitting์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„  ํ•™์Šต ๋ฐ์ดํ„ฐ์˜ ์–‘์„ ๋Š˜๋ฆฌ๊ฑฐ๋‚˜, Regularization์„ ์‚ฌ์šฉํ•ด ๋ชจ๋ธ์˜ weight๋ฅผ ๊ทœ์ œํ•˜๊ฑฐ๋‚˜, ๋ชจ๋ธ ํ•™์Šต์„ ๋๊นŒ์ง€ ํ•˜์ง€ ์•Š๊ณ  ์ค‘๊ฐ„์— ๋ฉˆ์ถ”๋Š” ๋ฐฉ๋ฒ•(Early-Stopping) ๋“ฑ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ์•ž์„œ ๋งํ–ˆ๋“ฏ์ด, Regularization์€ Overfitting์„ ๋ง‰๊ธฐ ์œ„ํ•ด weight(๊ฐ€์ค‘์น˜)์— ๊ทœ์ œ๋ฅผ ๊ฑฐ๋Š” ๊ฒƒ์ด๋‹ค.๋ชจ๋ธ์ด Overfitting ๋˜์—ˆ๋‹ค๋Š” ๊ฑด ๋ฐ์ดํ„ฐ ํ•˜๋‚˜ ํ•˜๋‚˜์— ๋ฏผ๊ฐํ•˜๊ฒŒ ๋ฐ˜์‘ํ•˜์—ฌ ์ผ๋ฐ˜์ ์ธ ํŒจํ„ด์ด ์•„๋‹Œ ๋ชจ..
LikelihoodLikelihood๋ฅผ ํ•œ๊ตญ์–ด๋กœ ๋ฒˆ์—ญํ•˜๋ฉด '(์–ด๋–ค ์ผ์ด ์žˆ์„) ๊ฐ€๋Šฅ์„ฑ' ์ด๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ํ†ต๊ณ„์—์„œ Likelihood๋Š” ์–ด๋–ค ๊ฐ€๋Šฅ์„ฑ์ผ๊นŒ?  ๋ฐ”๋กœ, ๋ฐ์ดํ„ฐ $\boldsymbol{X=\{x_1, x_2, x_3, x_4, x_5\}}$ ๊ฐ€ ํ™•๋ฅ  ๋ถ„ํฌ $\boldsymbol{P}$ ์—์„œ ๋‚˜์™”์„ ๊ฐ€๋Šฅ์„ฑ ์ด๋‹ค. Probability vs. Likelihoodํ†ต๊ณ„์—์„œ '๊ฐ€๋Šฅ์„ฑ'์ด๋ผ ํ•˜๋‹ˆ Probability(ํ™•๋ฅ )๊ฐ€ ์ƒ๊ฐ๋‚œ๋‹ค. Probability์™€ Likelihood๋Š” ๋‘˜ ๋‹ค '๋ฌด์–ธ๊ฐ€ ์ผ์–ด๋‚  ๊ฐ€๋Šฅ์„ฑ'์„ ๋œปํ•œ๋‹ค.๋Œ€์‹ , Probability๋Š” ์–ด๋–ค ์‚ฌ๊ฑด์ด ์ผ์–ด๋‚  ๊ฐ€๋Šฅ์„ฑ์„ ๋งํ•˜๊ณ  Likelihood๋Š” ์–ด๋–ค ์‚ฌ๊ฑด์ด ์–ด๋””์—์„œ ์ผ์–ด๋‚  ๊ฐ€๋Šฅ์„ฑ์„ ๋งํ•œ๋‹ค. ๋ˆˆ๊ธˆ์ด 6๊ฐœ์ธ ์ฃผ์‚ฌ์œ„๋ฅผ ๋˜์กŒ์„ ๋•Œ ์ˆซ์ž 1 ์ด๋‚˜ 2๊ฐ€ ๋‚˜..
Backpropagation (์—ญ์ „ํŒŒ)์ตœ์ ์˜ parameter ๊ฐ’์„ ์ฐพ๊ธฐ ์œ„ํ•ด cost์— ๋Œ€ํ•œ ์ž…๋ ฅ์ธต์˜ ๊ธฐ์šธ๊ธฐ๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ๊ฒƒ์ถœ๋ ฅ์ธต์˜ ๊ธฐ์šธ๊ธฐ๋ถ€ํ„ฐ ๊ณ„์‚ฐํ•˜์—ฌ ์—ญ์œผ๋กœ ์ „ํŒŒํ•˜๊ธฐ ๋•Œ๋ฌธ์— Backpropagation;์—ญ์ „ํŒŒ ๋ผ๊ณ  ํ•จChain Rule (ํ•ฉ์„ฑํ•จ์ˆ˜์˜ ๋ฏธ๋ถ„๋ฒ•) ์‚ฌ์šฉ Backpropagation in a Single Layer 1. forward pass → weighted sum, activation function(sigmoid)2. cost function → MSE3. backpropagation→ Chain Rule$\frac{\partial C}{\partial w_i}$ : 3๊ฐœ์˜ ํ•จ์ˆ˜๋กœ ์ด๋ฃจ์–ด์ง„ ํ•ฉ์„ฑํ•จ์ˆ˜ํ•ด๋‹น ํ•จ์ˆ˜์˜ ๊ธฐ์šธ๊ธฐ๋ฅผ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด ํ•ฉ์„ฑํ•จ์ˆ˜์˜ ๋ฏธ๋ถ„๋ฒ•์ธ Chain Rule ์ ์šฉ์œ„ ์‹์„ ์ด๋ฃจ๊ณ ..
Gradient Descent (๊ฒฝ์‚ฌ ํ•˜๊ฐ•๋ฒ•)loss function(์†์‹คํ•จ์ˆ˜) ๊ฐ’์ด ์ตœ์†Œ๊ฐ€ ๋˜๋Š” ๋ฐฉํ–ฅ์œผ๋กœ parameter ๊ฐ’์„ update ํ•˜๋Š” ๊ฒƒ์ตœ์†Œ๊ฐ€ ๋˜๋Š” ๋ฐฉํ–ฅ = Gradient ๋ฐ˜๋Œ€ ๋ฐฉํ–ฅ์‰ฌ์šด ๊ตฌํ˜„์„ฑ ๋ฐ ๋†’์€ ํ™•์žฅ์„ฑ, ๊ฑฐ์˜ ๋ชจ๋“  ์ตœ์ ํ™” ๋ฌธ์ œ์— ์ ์šฉ ๊ฐ€๋Šฅํ•จ  starting point = $\theta^0$ → randomly pick !$\theta^0$ ์—์„œ negative gradient ๋ฐฉํ–ฅ์œผ๋กœ ์ด๋™ → $-\nabla C(\theta^0)$$\theta = (W_1, W_2), \ \nabla C(\theta^0)=\begin{bmatrix} \frac{\partial C(\theta^0)}{\partial W_1} \\ \frac{\partial C(\theta^0)}{\partial ..
#JERO
'๐ŸŒ Jero's Wiki' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก