Skip to content

Instantly share code, notes, and snippets.

View pianopia's full-sized avatar

pianopia pianopia

View GitHub Profile
@pianopia
pianopia / microgpt.nim
Last active February 21, 2026 06:11
microgpt made with nim-lang from Andrej karpathy's microgpt
import std/[algorithm, httpclient, math, os, random, sequtils, sets, strformat, strutils, tables]
type
Value = ref object
data, grad: float
ch: seq[Value]
lg: seq[float]
Vec = seq[Value]
Mat = seq[Vec]
SD = OrderedTable[string, Mat]
Cache = seq[Mat] # [layer][time][channel]
# 2進数を10進数へ
bin2ten() {
echo "ibase=2; $@" | bc
}
# 10進数を2進数へ
ten2bin() {
echo "obase=2; $@" | bc
}