mnist-tflite

์ฑ… ใ€Ž๋ฐ‘๋ฐ”๋‹ฅ๋ถ€ํ„ฐ ๋งŒ๋“œ๋Š” ์ถ”๋ก  ์—”์ง„: Rust๋กœ ๋ฐฐ์šฐ๋Š” AI ์ธํผ๋Ÿฐ์Šค ์—”์ง€๋‹ˆ์–ด๋งใ€ (Building an Inference Engine from Scratch) 26์žฅ์—์„œ ์“ฐ๋Š” ์†๊ธ€์”จ ์ˆซ์ž ๋ถ„๋ฅ˜ ๋ชจ๋ธ ๋‘˜์ž…๋‹ˆ๋‹ค. .tflite ํŒŒ์ผ์ด๊ณ , ์ฑ…์˜ ๊ทธ๋ž˜ํ”„ ํ•ด์„๊ธฐ๊ฐ€ ์ฒ˜์Œ์œผ๋กœ ์ฝ๋Š” ํŒŒ์ผ์ž…๋‹ˆ๋‹ค.

Two tiny MNIST classifiers in the .tflite format, used in chapter 26 of the book. They are the first files read by the graph interpreter of the book's inference engine, badak.

๋ชจ๋ธ / Models

mlp.tflite residual.tflite
๊ตฌ์กฐ / Architecture 784 โ†’ 128 โ†’ 10, ReLU 784 โ†’ 256, ์ž”์ฐจ ๋ธ”๋ก 3๊ฐœ(256 โ†’ 512 โ†’ 256), 256 โ†’ 10
ํŒŒ๋ผ๋ฏธํ„ฐ / Parameters 101,770 992,266
์—ฐ์‚ฐ / Operators FULLY_CONNECTED ร— 2, SOFTMAX FULLY_CONNECTED ร— 8, ADD ร— 3, SOFTMAX
์‹œํ—˜ ์ •ํ™•๋„ / Test accuracy 97.64% (9,764 / 10,000) 97.73% (9,773 / 10,000)

๋‘ ๋ชจ๋ธ ๋ชจ๋‘ ์ž…๋ ฅ์€ 0๊ณผ 1 ์‚ฌ์ด์˜ ํ”ฝ์…€ ๊ฐ’ (1, 784)์ด๊ณ , ์ถœ๋ ฅ์€ ์ˆซ์ž 0~9์˜ ํ™•๋ฅ  (1, 10)์ž…๋‹ˆ๋‹ค. ์ •๊ทœํ™” (x โˆ’ 0.1307) / 0.3081์€ ๊ทธ๋ž˜ํ”„ ์•ˆ์— ๋“ค์–ด ์žˆ์Šต๋‹ˆ๋‹ค(๋ณ€ํ™˜๊ธฐ๊ฐ€ ์ฒซ ์ธต์˜ ๊ฐ€์ค‘์น˜์— ์ ‘์–ด ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค).

Both take pixel values in [0, 1] with shape (1, 784) and return ten probabilities. The normalization is part of the graph.

mlp.tflite์˜ ๊ฐ€์ค‘์น˜๋Š” mnist-mlp์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

ํŒŒ์ผ / Files

ํŒŒ์ผ ๋‚ด์šฉ
mlp.tflite 7์žฅ์˜ ๋ชจ๋ธ์„ ๊ทธ๋ž˜ํ”„๋กœ ์˜ฎ๊ธด ๊ฒƒ
residual.tflite ์ž”์ฐจ ์—ฐ๊ฒฐ์ด ์žˆ๋Š” ๋ชจ๋ธ
reference.safetensors LiteRT๊ฐ€ ๊ณ„์‚ฐํ•œ ์ •๋‹ต. ๋ชจ๋ธ๋งˆ๋‹ค ์•ž์˜ 16์žฅ์— ๋Œ€ํ•œ ํ™•๋ฅ (mlp.probabilities, residual.probabilities)๊ณผ ์‹œํ—˜ ๋ฐ์ดํ„ฐ ์ „์ฒด์˜ ์˜ˆ์ธก(mlp.predictions, residual.predictions)

๋งŒ๋“  ๋ฐฉ๋ฒ• / How it was made

์ €์žฅ์†Œ์˜ reference/ch26_make_tflite.py๋กœ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. PyTorch 2.14.1, litert-torch 0.10.0, ai-edge-litert 2.3.0. ์ž”์ฐจ ๋ชจ๋ธ์€ ๋‚œ์ˆ˜ ์”จ์•— 0, Adam(ํ•™์Šต๋ฅ  0.001), ๋ฐฐ์น˜ 64, 4 ์—ํญ, CPU๋กœ ํ•™์Šตํ–ˆ์Šต๋‹ˆ๋‹ค.

sh scripts/download_mnist.sh
sh scripts/download_ch07.sh
pip install -r reference/requirements_ch26.txt
python reference/ch26_make_tflite.py

๊ฐ™์€ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•ด๋„ ๊ธฐ๊ณ„์™€ ๋„๊ตฌ์˜ ๋ฒ„์ „์— ๋”ฐ๋ผ ํŒŒ์ผ์ด ์กฐ๊ธˆ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฑ…์˜ ์ˆซ์ž๋ฅผ ๊ทธ๋Œ€๋กœ ์žฌํ˜„ํ•˜๋ ค๋ฉด ์ด ์ €์žฅ์†Œ์˜ ํŒŒ์ผ์„ ์“ฐ์‹ญ์‹œ์˜ค.

ํ•œ๊ณ„ / Limitations

ํ•™์Šต ์žฌ๋ฃŒ๋ฅผ ๋ณด์—ฌ ์ฃผ๊ธฐ ์œ„ํ•œ ์ž‘์€ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. MNIST์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ๊ฐ€์šด๋ฐ ์ •๋ ฌ๋œ ํฐ ์ˆซ์ž, ๊ฒ€์€ ๋ฐฐ๊ฒฝ์˜ 28 ร— 28 ๊ทธ๋ฆผ์—์„œ๋งŒ ์ž˜ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

Downloads last month
179
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Dataset used to train building-an-inference-engine-from-scratch/mnist-tflite