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

IN DEPTH CAKE

(40)
[๋ชจ์•„ ๋†“๊ณ  ๋งํ•ด๋ณด์ž] ์ •๋ ฌ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ •๋ ฌ์ด ํ•„์š”ํ•œ ์ด์œ  = ํƒ์ƒ‰ ๋ฐ์ดํ„ฐ๊ฐ€ ์ •๋ ฌ๋˜์–ด ์žˆ๋‹ค๋ฉด '์ด์ง„ ํƒ์ƒ‰'์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด์ง„ ํƒ์ƒ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์ตœ์•…์˜ ๊ฒฝ์šฐ์—”์„œ O(log n)์˜ ์„ฑ๋Šฅ์„ ๋ณด์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ•๋ ฅํ•˜๋ฉฐ, ์ด๋ฅผ ์œ„ํ•ด์„œ๋Š” ์ •๋ ฌ์ด ์„ ํ–‰๋˜์–ด์•ผํ•œ๋‹ค. ๋Œ€ํ‘œ์ ์ธ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ [Bubble Sort] ํ‰๊ท  ์‹คํ–‰ ์‹œ๊ฐ„ : $O(n^2)$ / ์ตœ์•… ์‹คํ–‰ ์‹œ๊ฐ„ : $O(n^2)$ / ๋ฉ”๋ชจ๋ฆฌ $O(1)$ ํ•œ ๋ฒˆ iteration์„ ๋Œ๋•Œ๋งˆ๋‹ค ํ•˜๋‚˜์˜ ๊ฐ’์„ ์ •๋ ฌํ•œ๋‹ค. ํ•œ ๋ฒˆ์˜ iteration์—์„œ ์ฒซ๋ฒˆ์งธ, ๋‘๋ฒˆ์งธ๋ฅผ ๋น„๊ต, ๋‘๋ฒˆ์งธ์™€ ์„ธ๋ฒˆ์งธ๋ฅผ ๋น„๊ต ... ์ด๋Ÿฐ ํ˜•ํƒœ๋กœ $n-1$๋ฒˆ์งธ์™€ $n$๋ฒˆ์งธ๋ฅผ ๋น„๊ตํ•จ์œผ๋กœ์จ ๋งˆ์ง€๋ง‰ ๊ฐ’์„ ์ •๋ ฌํ•œ ํ›„ ๋‹ค์‹œ ์•ž์—์„œ๋ถ€ํ„ฐ ๋น„๊ตํ•ด์„œ $n-1$๋ฒˆ์งธ ๊ฐ’์„ ์ •๋ ฌํ•˜๋Š” ํ˜•ํƒœ๋กœ ๋™์ž‘ํ•œ๋‹ค. ์ตœ์•…์˜ ๊ฒฝ์šฐ์— ๋งค iteration๋งˆ๋‹ค ์ฒ˜์Œ๋ถ€ํ„ฐ ๋๊นŒ์ง€ ๋‹ค ..
sphinx-js ๋กœ javascript ์ฝ”๋“œ ๋ฌธ์„œํ™”ํ•˜๊ธฐ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ๋‹จ/ํ•˜๋‹จ์— ๊ฐ„ํ—์ ์œผ๋กœ ๋œจ๋Š” ๊ด‘๊ณ ๋Š” ๋ธ”๋กœ๊ทธ ๊ฐœ์ธ ์ˆ˜์ต๊ณผ ๊ด€๋ จ ์—†๋Š” ํ‹ฐ์Šคํ† ๋ฆฌ ์ธก ๊ด‘๊ณ ์ž…๋‹ˆ๋‹ค ์†Œ๊ฐœ ์•ˆ๋…•ํ•˜์„ธ์š”. ์˜ค๋Š˜์€ javascript๋กœ ์ฝ”๋”ฉ๋œ ํ”„๋กœ์ ํŠธ์˜ ๋ฌธ์„œํ™”๋ฅผ ์œ„ํ•œ sphinx-js๋ฅผ ์„ค๋ช…ํ•ด๋“œ๋ฆฌ๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. sphinx๋Š” python ํ”„๋กœ์ ํŠธ์˜ ๋ฌธ์„œ ์ž๋™ํ™”๋ฅผ ์œ„ํ•œ ํˆด์ž…๋‹ˆ๋‹ค. python ํ”„๋กœ์ ํŠธ์˜ ํ•จ์ˆ˜, ๋ชจ๋“ˆ๋“ค์— ํŠน์ • ๋ฌธ๋ฒ•์„ ๋”ฐ๋ผ ์ฃผ์„์„ ์ž‘์„ฑํ•ด ๋‘๋ฉด ์ž๋™์œผ๋กœ latex ๋ฌธ์„œ, html๋กœ ๋นŒ๋“œํ•ด ์ฃผ๋Š” ํˆด์ด์—์š”. ์˜คํ”ˆ ์†Œ์Šค ํ”„๋กœ์ ํŠธ์˜ ๋ฌธ์„œํ™” ๋“ฑ์— ๋งŽ์ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. javascript์šฉ์œผ๋กœ ์œ ์‚ฌํ•œ ํˆด jsdoc ์ด ์žˆ์ง€๋งŒ, read-the-docs ์™€ ์—ฐ๋™ํ•ด์„œ ๋นŒ๋“œํ•˜๊ณ  ์‹ถ์–ด์„œ ์ฐพ๊ฒŒ ๋œ ๊ฒŒ ๋ฐ”๋กœ sphinx-js์˜ˆ์š”. GitHub - mozilla/sphinx-js: Autodoc-style ex..
No module named 'tensorboard' ํ•ด๊ฒฐ [์ฆ์ƒ] ์ž˜ ์‚ฌ์šฉ์ค‘์ด๋˜ conda ํ™˜๊ฒฝ์—์„œ tensorboard๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค๊ณ  ์—๋Ÿฌ๊ฐ€ ๋–ด๋‹ค. ๋‹ค๋ฅธ ๊ฐ€์ƒ ํ™˜๊ฒฝ๋“ค์—์„œ๋„ ๋ชจ๋‘ ๋™์ผํ•œ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๊ฐ€ ๋ฐœ๊ฒฌ๋˜์—ˆ๋‹ค. pip ๋ž‘ conda๋กœ tensorboard ํŒจํ‚ค์ง€ ์‚ญ์ œ๋ฅผ ํ•ด์คฌ๋Š”๋ฐ๋„ ์—๋Ÿฌ๊ฐ€ ๊ณ„์† ๋–ด๋‹ค. Traceback (most recent call last): File "~/.local/bin/tensorboard", line 7, in line 7, in from tensorboard.main import run_main ImportError: No module named 'tensorboard' [ํ•ด๊ฒฐ] bin ํด๋”๋ฅผ ์•„์˜ˆ ์‚ญ์ œํ–ˆ๋‹ค rm -rf ~/.bin/tensorboard ๋‹ค์‹œ conda ํ™˜๊ฒฝ ์—์„œ ๋ชจ๋“ˆ์„ ์žฌ ์„ค์น˜ํ•ด์ฃผ์—ˆ๋‹ค. pip install..
[pytorch] RuntimeError: one_hot is only applicable to index tensor import torch.nn.functional as F bs = 10 F.one_hot(torch.ones(bs)*2, 5) 2์— ๋Œ€์‘๋˜๋Š” ์ „์ฒด ํฌ๊ธฐ๋Š” 5์ธ one hot encoding vector๋ฅผ batch size๊ฐœ์ˆ˜๋งŒํผ ๋งŒ๋“ค๊ณ  ์‹ถ์–ด์„œ ์œ„์™€ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ๊ฐ€ ๋œฌ๋‹ค. RuntimeError: one_hot is only applicable to index tensor. one_hot ํ•จ์ˆ˜๋Š” index tensor (ํƒ€์ž… ๋ช…์ด torch.int64)๋ฅผ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ์ด๋‹ค. ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. >>> torch.nn.functional.one_hot((torch.ones(bs)*2).to(torch.int64), 5) tensor([[0, 0, 1, 0..
[python] Anaconda ํ™˜๊ฒฝ yamlํŒŒ์ผ export ๋ฐ import (ํ™˜๊ฒฝ ์ƒ์„ฑ create, ํ™œ์„ฑํ™” activate ๋“ฑ) Anaconda ๋Š” python ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ๋ฅผ ์ง€์›ํ•˜๋Š” ํ”„๋ ˆ์ž„์›Œํฌ์ž…๋‹ˆ๋‹ค. Anaconda๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฐ€์žฅ ํฐ ์žฅ์  ์ค‘์— ํ•˜๋‚˜๋Š”, ์šฉ๋„์— ๋งž์ถ”์–ด ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค๊ณ  ๊ทธ ํ™˜๊ฒฝ ๋‚ด์—์„œ๋งŒ ํŒจํ‚ค์ง€ ์˜์กด์„ฑ์„ ๊ด€๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. ์ด๊ฒŒ ์™œ ํฐ ์žฅ์ ์ด ๋˜๋Š๋ƒ, ์ด ๊ฐ€์ƒ ํ™˜๊ฒฝ (environment)๋งŒ ์˜ฎ๊ฒจ์ฃผ๋ฉด ํ•ด๋‹น ์ฝ”๋“œ๋ฅผ ๊ทธ๋Œ€๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด์ฃ . ์ด๋Ÿฌํ•œ ๊ธฐ๋Šฅ์€ ์ฝ”๋“œ ๋ฐฐํฌ๋ฅผ ๊ฐ„ํŽธํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค. ๊ณต๊ฐœ ์†Œํ”„ํŠธ์›จ์–ด๋‚˜, ๋‚ด ๋…ผ๋ฌธ์„ ๊ตฌํ˜„ ์ฝ”๋“œ๋ฅผ ๊ณต๊ฐœํ•˜๊ณ ์žํ•  ๋•Œ, ๊ฐœ๋ฐœํ•˜๊ณ ์žํ•˜๋Š” ์‘์šฉ์„์œ„ํ•œ ์ „์šฉ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค๊ณ , ๊ทธ ํ™˜๊ฒฝ์„ ๊ทธ๋Œ€๋กœ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋„๋กํ•˜๋Š” ์˜์กด์„ฑ ์ •๋ณด๋งŒ ๋ฐฐํฌํ•ด์ฃผ๋ฉด ๋ˆ„๊ตฌ๋“ ์ง€ ๋™์ผํ•œ ํ™˜๊ฒฝ์„ ์žฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ค๋Š˜์€ ๊ฐ€์ƒ ํ™˜๊ฒฝ ๊ด€๋ฆฌ์™€ ๊ด€๋ จ๋œ ๋ช‡๊ฐ€์ง€๋ฅผ ๊ฐ„๋žตํžˆ ์ •๋ฆฌํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ชฉ์ฐจ 1. conda ํ™˜๊ฒฝ ..
[C++] reference ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ์ดํ•ด (pointer์™€ ๋น„๊ต) ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ๋‹จ์— ๊ฐ„ํ—์ ์œผ๋กœ ๋œจ๋Š” ๊ด‘๊ณ ๋Š” ๋ธ”๋กœ๊ทธ ๊ฐœ์ธ ์ˆ˜์ต๊ณผ ๊ด€๋ จ ์—†๋Š” ํ‹ฐ์Šคํ† ๋ฆฌ ์ธก ์ˆ˜์ต ๊ด‘๊ณ ์ž…๋‹ˆ๋‹ค C์—์„œ ์ฃผ์†Œ๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ฐฉ์‹์œผ๋กœ pointer๊ฐ€ ์ œ๊ณต๋œ๋‹ค. pointer๋Š” ๊ทธ ์ด๋ฆ„๋งŒ์œผ๋กœ๋„ ๊ดœํžˆ ๋งˆ์Œ์„ ๋ถˆํŽธํ•˜๊ฒŒ ํ•œ๋‹ค. ๊ดœํžˆ ์ž˜๋ชป ์“ฐ๋ฉด dangling pointer ๋ฌธ์ œ๊ฐ€ ์ผ์–ด๋‚  ๊ฒƒ ๊ฐ™๊ณ , ๋ง‰ ๊ทธ๋ ‡๋‹ค. C++์—์„œ๋Š” ์ด๋Ÿฐ ๊ฐœ๋ฐœ์ž๋“ค์˜ ์‹ฌ์  ๋ถ€๋‹ด์„ ๋œ์–ด์ฃผ๊ธฐ ์œ„ํ•ด ์ฃผ์†Œ๋ฅผ ํ•ธ๋“ค๋งํ•  ์ˆ˜ ์žˆ๋Š” ๋˜ ๋‹ค๋ฅธ ๋ฐฉ์‹์œผ๋กœ reference๋ผ๋Š” ๋ฐฉ์‹์„ ์ œ๊ณตํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด, pointer์™€ reference์˜ ์ฐจ์ด๋Š” ๋ฌด์—‡์ผ๊นŒ? ์“ฐ๋Š” ๋ฌธ๋ฒ•์ด ๋‹ค๋ฅด๋‹ค๋Š” ์‹์ƒํ•œ ๋‹ต๋ณ€ ๋ง๊ณ , reference๋งŒ์˜ ์žฅ์ ์„ ๋ถ€๊ฐํ•  ์ˆ˜ ์žˆ๋Š” ์˜ˆ์ œ๋ฅผ ํ•œ๋ฒˆ ๋ณด๊ณ  ๋„˜์–ด๊ฐ€๋ฉด ์ข‹๋‹ค. (๊ทธ๋ž˜์•ผ C++์—์„œ reference๋ผ๋Š” ๊ธฐ๋Šฅ์„ ๋„์ž…ํ•œ ์ด์œ ๋ฅผ ์ œ๋Œ€๋กœ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋‹ค) ๋ชฉ..
<ML๋…ผ๋ฌธ> CVAE์— ๋Œ€ํ•˜์—ฌ (feat. ๋ˆ„๊ฐ€ ์ง„์งœ CVAE์ธ๊ฐ€? ํ•˜๋‚˜์˜ ์ด๋ฆ„, ๋‘ ๊ฐœ์˜ ๊ธฐ๋ฒ•) ๋ณธ ๊ธ€์€ ๋…ผ๋ฌธ์˜ ์ƒ์„ธ ๋‚ด์šฉ์„ ๋‹ค๋ฃจ๋Š” ํฌ์ŠคํŒ…์€ ์•„๋‹ˆ์—์š”. ๋‹ค๋งŒ, ๋‘ ๊ฐœ์˜ ๋…ผ๋ฌธ์ด ํ•˜๋‚˜์˜ ์ด๋ฆ„์œผ๋กœ ๋ถˆ๋ฆฌ๊ณ  ์žˆ๊ธธ๋ž˜, '์ด์— ๋Œ€ํ•œ ํ˜ผ์„ ์„ ์ •๋ฆฌํ•˜๋Š” ๊ธ€์„ ์จ๋ณด์ž'ํ•˜๋Š” ๋งˆ์Œ์œผ๋กœ ๊ธ€์„ ์ผ์Šต๋‹ˆ๋‹ค. ๋ฌผ๋ก  ๊ฐ„๋žตํ•˜๊ฒŒ ๊ฐ๊ฐ์˜ ๋…ผ๋ฌธ ๋‚ด์šฉ์„ ๋‹ค๋ฃจ๊ณ  ์žˆ๊ธฐ๋Š” ํ•ฉ๋‹ˆ๋‹ค๋งŒ, ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๊ฐ ๋…ผ๋ฌธ ๋‚ด์šฉ์„ ์„ค๋ช…ํ•˜๋Š” ๊ธ€์„ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์•ˆ๋…•ํ•˜์„ธ์š”. ์˜ค๋Š˜์€ ๊ฐœ์ธ์ ์œผ๋กœ ํฅ๋ฏธ๋กœ์› ๋˜ ํ˜„์ƒ์— ๋Œ€ํ•ด ์ ์–ด๋ณผ๊นŒ ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ณธ๋ฌธ์„ ์ฝ๊ณ  ๊ณ„์‹  99.9 % ์˜ ๋ถ„๋“ค์€ "CVAE"๋ผ๋Š” ํ‚ค์›Œ๋“œ๋ฅผ ๊ฒ€์ƒ‰ํ•˜์…จ์„ ๊ฒƒ ๊ฐ™์•„์š”. ์—ฌ๋Ÿฌ๋ถ„์ด ์ด ๊ธ€์„ ํด๋ฆญํ•˜์‹ค ๋•Œ ์ƒ๊ฐํ•˜์‹  CVAE๋Š” ์–ด๋–ค ๋…€์„์ธ๊ฐ€์š”? ์งˆ๋ฌธ์ด ์ด์ƒํ•˜์ฃ ? ์ œ๊ฐ€ ์˜ค๋Š˜ ์ด ๊ธ€์„ ์“ฐ๊ธฐ๋กœ ๋งˆ์Œ๋จน์€ ๋ฐ๋Š” ์ด์œ ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ œ๊ฐ€ ๊ฒ€์ƒ‰์„ ํ•˜๋‹ค๊ฐ€ ๋ฐœ๊ฒฌํ•œ ํ˜„์ƒ์ด ์žˆ๋Š”๋ฐ, ๋ฐ”๋กœ ๋‘ ๊ฐœ์˜ (์œ ๊ด€ํ•˜์ง€๋งŒ ์„œ๋กœ ๋‹ค๋ฅธ) ๋…ผ๋ฌธ์ด ..
<VSCode ๋ฅผ C++ IDE๋กœ ์“ฐ๊ธฐ> Mac์—์„œ C++ ๊ฐœ๋ฐœํ•˜๊ธฐ ์ผ๋ฐ˜์ ์œผ๋กœ C++ ๊ฐœ๋ฐœํ•œ๋‹ค๊ณ ํ•˜๋ฉด ๋Œ€ํ‘œ์ ์œผ๋กœ ์“ฐ๋Š” IDE๊ฐ€ Visual Studio์ด์ง€๋งŒ, ๋งฅ์—์„œ๋Š” Visual Studio๊ฐ€ C++ ๊ฐœ๋ฐœํ™˜๊ฒฝ์„ ์ง€์›ํ•ด์ฃผ์ง€ ์•Š๋Š”๋‹ค. ๊ทธ๋ž˜์„œ ๋Œ€์ฒด์ œ๋กœ ๋งŽ์ด ์“ฐ๋Š”๊ฒŒ VSCode๋‹ค. โ–ผโ–ผโ–ผ VS Code ์„ค์น˜๋Š” ์š”๊ธฐ โ–ผโ–ผโ–ผ Download Visual Studio Code - Mac, Linux, Windows Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern we..