๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

IN DEPTH CAKE

(40)
[์ฝ”๋”ฉ/LeetCode150-(3)] Remove Duplicates from Sorted Array (26) ๋ณธ ๊ธ€์€ LeetCode Top Interview 150์— ์ •๋ฆฌ๋œ ๋ฌธ์ œ๋ฅผ ์š”์•ฝํ•˜๊ณ  ์ด์— ๋Œ€ํ•œ ๊ฐœ์ธ์ ์ธ ํ’€์ด๋ฅผ ํฌํ•จํ•˜๊ณ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ณธ ํฌ์ŠคํŒ… ์‹œ๋ฆฌ์ฆˆ๋Š” 150 list์˜ ์ˆœ์„œ๋ฅผ ๋”ฐ๋ผ์„œ ๊ฒŒ์žฌ๋ฉ๋‹ˆ๋‹ค. ํ’€์ด ์–ธ์–ด๋Š” python์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‚œ์ด๋„: EASY ํ‚ค์›Œ๋“œ: Array, Two-Pointers ๋ฌธ์ œ ๋ฌธ์ œ์›๋ฌธ: https://leetcode.com/problems/remove-duplicates-from-sorted-array/?envType=study-plan-v2&envId=top-interview-150 ์ฃผ์–ด์ง„ ๊ฐ์†Œํ•˜์ง€ ์•Š๋Š” ์ˆœ์„œ๋กœ ์ •๋ ฌ๋œ ์ •์ˆ˜ ๋ฐฐ์—ด nums์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, ์˜ค์ง uniqueํ•œ ๊ฐ’๋งŒ ์žˆ๋„๋ก in-placeํ˜•ํƒœ๋กœ nums๋ฅผ ์—…๋ฐ์ดํŠธํ•ด๋ผ. (๋‹ค์‹œ ๋งํ•ด, ์ค‘๋ณต๋œ ๊ฐ’์„ ์ œ๊ฑฐํ•ด๋ผ) ์ด ๋•Œ ๊ฐ’๋“ค์˜..
[์ฝ”๋”ฉ/LeetCode150-(2)] Remove Element (27) ๋ณธ ๊ธ€์€ LeetCode Top Interview 150์— ์ •๋ฆฌ๋œ ๋ฌธ์ œ๋ฅผ ์š”์•ฝํ•˜๊ณ  ์ด์— ๋Œ€ํ•œ ๊ฐœ์ธ์ ์ธ ํ’€์ด๋ฅผ ํฌํ•จํ•˜๊ณ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ณธ ํฌ์ŠคํŒ… ์‹œ๋ฆฌ์ฆˆ๋Š” 150 list์˜ ์ˆœ์„œ๋ฅผ ๋”ฐ๋ผ์„œ ๊ฒŒ์žฌ๋ฉ๋‹ˆ๋‹ค. ํ’€์ด ์–ธ์–ด๋Š” python3์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‚œ์ด๋„: EASY ํ‚ค์›Œ๋“œ: Array, Two-Pointers ๋ฌธ์ œ ๋ฌธ์ œ ์›๋ฌธ: https://leetcode.com/problems/remove-element/?envType=study-plan-v2&envId=top-interview-150 ์ •์ˆ˜ ๋ฐฐ์—ด nums์™€ ์ •์ˆ˜ val ์ด ์ฃผ์–ด์กŒ์„ ๋•Œ nums ๋‚ด์— val ๊ฐ’์„ in-place ํ˜•ํƒœ๋กœ ์ œ๊ฑฐํ•ด๋ผ. ์ด ๋•Œ ์š”์†Œ (elements)๋“ค์˜ ์ˆœ์„œ๋Š” ๋ฐ”๋€” ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๋ ‡๊ฒŒ ์—…๋ฐ์ดํŠธ ๋œ nums ๋‚ด์˜ element์˜ ์ˆ˜๋ฅผ ๋ฐ˜..
[์ฝ”๋”ฉ/LeetCode150-(1)] Merge Sorted Array (88) ๋ณธ ๊ธ€์€ LeetCode Top Interview 150์— ์ •๋ฆฌ๋œ ๋ฌธ์ œ๋ฅผ ์š”์•ฝํ•˜๊ณ  ์ด์— ๋Œ€ํ•œ ๊ฐœ์ธ์ ์ธ ํ’€์ด๋ฅผ ํฌํ•จํ•˜๊ณ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ณธ ํฌ์ŠคํŒ… ์‹œ๋ฆฌ์ฆˆ๋Š” 150 list์˜ ์ˆœ์„œ๋ฅผ ๋”ฐ๋ผ์„œ ๊ฒŒ์žฌ๋ฉ๋‹ˆ๋‹ค. ํ’€์ด ์–ธ์–ด๋Š” python์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‚œ์ด๋„: EASY ํ‚ค์›Œ๋“œ: Array, Two-Pointers ๋ฌธ์ œ ๋ฌธ์ œ ์›๋ฌธ: https://leetcode.com/problems/merge-sorted-array/?envType=study-plan-v2&envId=top-interview-150 ๊ฐ์†Œํ•˜์ง€ ์•Š๋Š” ํ˜•ํƒœ๋กœ ์ •๋ ฌ๋œ ๋‘ ๊ฐœ์˜ integer array nums1 ์ด๋ž‘ nums2์˜ ๊ฐ๊ฐ์˜ ๊ธธ์ด (์ •์ˆ˜๊ฐ€ ๋“ค์–ด์žˆ๋Š” ๋ฐฐ์—ด๋ถ€๋ถ„์˜ ๊ธธ์ด)๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋‘ ๊ฐœ์˜ ์ •์ˆ˜ m๊ณผ n์ด ์ฃผ์–ด์กŒ๋‹ค. ๋‘ ๊ฐœ์˜ array๋ฅผ ๊ฐ์†Œํ•˜์ง€ ์•Š๋Š” ์ˆœ์œผ๋กœ ..
<ML๋…ผ๋ฌธ> ํด๋ž˜์Šค ๋ถˆ๊ท ํ˜• ๋ฌธ์ œ Cui et al. "Class-Balanced Loss Based on Effective Number of Samples" (CVPR 2019) TL;DR Class imbalance ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ฐ์ดํ„ฐ์…‹ ๊ฐ ํด๋ž˜์Šค์˜ ์œ ํšจ ๋ฐ์ดํ„ฐ ์ˆ˜๋ฅผ ์ •์˜ํ•˜๊ณ  ์ด๋ฅผ ํ™œ์šฉํ•œ re-weighting๊ธฐ๋ฐ˜ Class Balance Loss ๊ธฐ๋ฒ• ์ œ์•ˆ. ๋ฌด์Šจ ๋ฌธ์ œ๋ฅผ ํ’€๊ณ  ์žˆ๋‚˜? ๋”ฅ๋Ÿฌ๋‹ ๋ชจ๋ธ ํ•™์Šต์— ์‚ฌ์šฉ๋˜๋Š” ์ผ๋ฐ˜์ ์ธ ๋ฐ์ดํ„ฐ ์…‹ (์˜ˆ๋ฅผ๋“ค์–ด CIFAR-10, 100, ImageNet ๋“ฑ)์ด ํด๋ž˜์Šค ๋ผ๋ฒจ ๋ถ„ํฌ๊ฐ€ ๊ท ์ผํ•œ ๊ฒƒ๊ณผ ๋‹ฌ๋ฆฌ, ์‹ค์ œ ์ƒํ™ฉ์—์„œ๋Š” ๋ชจ๋“  ํด๋ž˜์Šค์˜ ๋ฐ์ดํ„ฐ ์ˆ˜๊ฐ€ ๊ท ์ผํ•˜๊ฒŒ ์ˆ˜์ง‘๋˜์ง€ ์•Š๋Š”, Long Tail ํ˜„์ƒ์ด ๋ฐœ์ƒํ•œ๋‹ค. ์—ฌ๊ธฐ์„œ Long Tail์ด๋ผ๊ณ ํ•จ์€, ๊ฐ ํ•™์Šต ๋ฐ์ดํ„ฐ ์˜ ํด๋ž˜์Šค ๋ณ„ ์ƒ˜ํ”Œ ์ˆ˜์— ๋Œ€ํ•œ ๋ถ„ํฌ๋ฅผ ๊ทธ๋ ธ์„ ๋•Œ ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด, ์†Œ์ˆ˜์˜ ํด๋ž˜์Šค์— ๋Œ€ํ•ด์„œ ๋ฐ์ดํ„ฐ ์ƒ˜ํ”Œ ์ˆ˜๊ฐ€ ๋งŽ์€ ๋ฐ ๋ฐ˜ํ•ด (Head) ๋‹ค์ˆ˜์˜ ํด๋ž˜์Šค์—์„œ ๊ธฐ๋Œ€์น˜ ์ดํ•˜์˜ ์ƒ˜ํ”Œ ์ˆ˜๋ฅผ ๊ฐ–๋Š” (..
[์•Œ๊ณ ๋ฆฌ์ฆ˜] ์ด์ง„ ํƒ์ƒ‰ (Binary Search) - ์ค‘๋ณต๋œ ๊ฐ’์ด ์žˆ๋Š” ๊ฒฝ์šฐ๊นŒ์ง€ ์‚ดํŽด๋ณด๊ธฐ ๋ชฉ์ฐจ ๐ŸŒ  ๊ฐœ์š” ์ด์ง„ ํƒ์ƒ‰ ์„ค๋ช… ์ด์ง„ ํƒ์ƒ‰ template Array ๋‚ด์— ์ค‘๋ณต๋œ ๊ฐ’์ด ์—†๋Š” ๊ฒฝ์šฐ Array ๋‚ด์— ์ค‘๋ณต๋œ ๊ฐ’์ด ์žˆ๋Š” ๊ฒฝ์šฐ ์ฃผ์š” ํŒจํ„ด ์„ค๋ช…์€ ๋‹ค์Œ์—... ๊ฐœ์š” ์ด์ง„ ํƒ์ƒ‰์€ ํฌ๊ธฐ๊ฐ€ $n$ ์ธ search space์—์„œ ์‚ฌ์šฉ๋˜๋Š” ํƒ์ƒ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ, worst case์—์„œ์˜ ๋ณต์žก๋„๊ฐ€ $O(\log n)$ ์ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ์ด์ง„ ํƒ์ƒ‰์€ ์ •๋ ฌ๋˜์–ด ์žˆ๋Š” ํƒ์ƒ‰ ๊ณต๊ฐ„์— ๋Œ€ํ•ด์„œ ์ ์šฉ๋œ๋‹ค. ์ด์ง„ ํƒ์ƒ‰์ด ์‚ฌ์šฉ๋˜๋Š” ๊ฒฝ์šฐ๋“ค ์ค‘ ์˜ˆ๋ฅผ ๋“ค์–ด๋ณด์ž๋ฉด... ์ •๋ ฌ๋œ ๋ฐฐ์—ด์ด ์ฃผ์–ด์ง€๊ณ  ํŠน์ • ๊ฐ’์ด ์ถ”๊ฐ€๋˜์–ด์•ผ ํ•  ์œ„์น˜๋ฅผ ๋ฌผ์–ด๋ณด๋Š” ๊ฒฝ์šฐ ์ •๋ ฌ๋˜์ง€ ์•Š์€ ๋ฐฐ์—ด์— ๋Œ€ํ•ด์„œ ํŠน์ • ๊ฐ’ ๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ์ž‘์€ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋Š” ๊ฐœ์ˆ˜๋ฅผ ๋ฌผ์–ด๋ณด๋Š” ๊ฒฝ์šฐ ์ด๋Ÿฌํ•œ ๋ฌธ์ œ๋Š” ์ฃผ๋กœ ์ฃผ์–ด์ง„ ๋ฐฐ์—ด์ด ์กฐ๊ฑด ๋งŒ์กฑ ์—ฌ๋ถ€์— ๋”ฐ๋ผ ๋‘ ๊ฐœ์˜ ์˜์—ญ (๊ฐ€๋Šฅ, ๋ถˆ๊ฐ€๋Šฅ)์œผ๋กœ ๋‚˜๋‰˜..
[์ฝ”๋”ฉ] ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ ๊ตฌํ•˜๊ธฐ - ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ• (Euclidean Algorithm) ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ• ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ•์ด๋ž€ ๋‹ค์Œ์˜ ์„ฑ์งˆ์„ ์ด์šฉํ•˜์—ฌ ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ (Greatest Common Divisor, GCD) ๋ฅผ ๊ตฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค: ๋‘ ์ˆ˜ A์™€ B๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•˜์ž (A > B) ์ด ๋•Œ, A์™€ B๋ฅผ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€ R์ด๋ผ๊ณ  ํ•  ๋•Œ, A์™€ B์˜ ์ตœ๋Œ€ ๊ณต์•ฝ์†Œ๋Š” B์™€ R์˜ ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜์™€ ๊ฐ™๋‹ค. ํ•œ ๋งˆ๋””๋กœ GCD(A,B) = GCD(B, R)์ด ์„ฑ๋ฆฝํ•œ๋‹ค๋Š” ๊ฑด๋ฐ, ์กฐ๊ธˆ ์ƒ๊ฐํ•ด๋ณด๋ฉด ์ด ํŠน์ง•์œผ๋กœ๋ถ€ํ„ฐ ์žฌ๊ท€์ ์ธ ์„ฑ์งˆ์„ ๋„์ถœํ•  ์ˆ˜ ์žˆ์Œ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค. ์ฆ‰, B๊ณผ R ์—ญ์‹œ B > R์ด ์„ฑ๋ฆฝํ•˜๋ฏ€๋กœ B๋ฅผ R๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ X๋ผ๊ณ ํ•˜๋ฉด ๊ฒฐ๊ตญ GCD(A,B) = GCD(B,R) = GCD(R,X) = ... ์ด ์„ฑ๋ฆฝํ•œ๋‹ค. ์ด ๋•Œ, ๋‘ ๊ฐ’์„ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๊ฐ€ 0์ผ ๋•Œ ๊ฐ’๋“ค์˜ ์•ฝ์ˆ˜๋Š” ํ•˜๋‚˜์ด๋ฏ€๋กœ ์ตœ์ข…์ ์œผ๋กœ ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๋ฅผ ๊ตฌํ•  ์ˆ˜..
arXiv์— preprint ์˜ฌ๋ฆฌ๊ธฐ ์ตœ๊ทผ arXiv์— preprint๋ฅผ ์˜ฌ๋ฆฌ๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ฆ๊ฐ€ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. preprint๋Š” peer-review๋ฅผ ๊ฒช๊ธฐ ์ „ ๋…ผ๋ฌธ์„ ์‚ฌ์ „ ๊ณต๊ฐœํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์œผ๋กœ ๋งŽ์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ํŠนํžˆ ์ตœ๊ทผ ์—ฐ๊ตฌ์˜ ๋ณ€ํ™”๊ฐ€ ๋นจ๋ผ์ง์— ๋”ฐ๋ผ ์šฐ์„ ๊ถŒ์„ ์ฃผ์žฅํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์œผ๋กœ ๋งŽ์ด ํ™œ์šฉ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. 1. ์ œ์ถœ์šฉ Latex ํŒŒ์ผ ์ค€๋น„ํ•˜๊ธฐ ์˜ค๋Š˜์€ Overleaf๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ž‘์„ฑํ•œ latex ํŒŒ์ผ์„ arXiv์— ์˜ฌ๋ฆฌ๋Š” ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. arXiv์—์„œ๋Š” ์ผ๋ฐ˜์ ์ธ overleaf์—์„œ ์ปดํŒŒ์ผ๋˜๋Š” pdf์™€๋Š” ์กฐ๊ธˆ ๋‹ค๋ฅธ ํ˜•์‹์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ overleaf์˜ Submit > arXiv > Download project Zip with submission files๋ฅผ ๋ˆ„๋ฅด๋ฉด ์กฐ๊ธˆ ๋” ์†์‰ฝ๊ฒŒ ์ œ์ถœ์šฉ latex ํŒŒ์ผ์„ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. * ํ•œ..
Overleaf `\usepackage{kotex}` ์ปดํŒŒ์ผ ์—๋Ÿฌ (latex์—์„œ ํ•œ๊ธ€ ์‚ฌ์šฉ) [overleaf latex์—์„œ ํ•œ๊ธ€ ์‚ฌ์šฉ + ์—๋Ÿฌ] \usepackage{kotex} latex์— ํ•œ๊ธ€์„ ํฌํ•จ์‹œํ‚ค๋ ค๊ณ ํ•˜๋ฉด \usepackage{kotex} ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•ด์ค˜์•ผํ•œ๋‹ค. ์—ฌ๋Š๋•Œ์™€๊ฐ™์ด latex์—์„œ ๋ณธ ํŒจํ‚ค์ง€ importํ•  ๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ปดํŒŒ์ผ ์—๋Ÿฌ๊ฐ€ ๋œฐ ์ˆ˜ ์žˆ๋‹ค. (์ž‘๋…„๊นŒ์ง„ ์ž˜๋๋Š”๋ฐ ๊ฐ‘์ž๊ธฐ ์™œ ์ด๋Ÿฌ์ง€?) โ–บ latex ๋ฒ„์ „๋•Œ๋ฌธ์ด๋‹ค [ํ•ด๊ฒฐ๋ฐฉ๋ฒ•] 1. Overleaf [Menu] ํด๋ฆญ 2. Tex Live version ํด๋ฆญ โ–บ2021 ์ด์ „ ๋ฒ„์ „์—์„œ ์ž˜ ๋™์ž‘ํ•œ๋‹ค. ๋