mirror of https://github.com/commaai/tinygrad.git
minor cleanups, yolo work
This commit is contained in:
parent
0825cf7f79
commit
6842ad9ec8
|
@ -13,7 +13,7 @@ jobs:
|
|||
- name: Install SLOCCount
|
||||
run: sudo apt-get install sloccount
|
||||
- name: Check <1000 lines
|
||||
run: sloccount tinygrad test examples; if [ $(sloccount tinygrad | sed -n 's/.*Total Physical Source Lines of Code (SLOC)[ ]*= \([^ ]*\).*/\1/p' | tr -d ',') -gt 1000 ]; then exit 1; fi
|
||||
run: sloccount tinygrad test examples extra; if [ $(sloccount tinygrad | sed -n 's/.*Total Physical Source Lines of Code (SLOC)[ ]*= \([^ ]*\).*/\1/p' | tr -d ',') -gt 1000 ]; then exit 1; fi
|
||||
|
||||
linter:
|
||||
name: Indentation Linter
|
||||
|
|
|
@ -5,27 +5,29 @@ from extra.utils import fetch, my_unpickle
|
|||
|
||||
if __name__ == "__main__":
|
||||
dat = fetch('https://github.com/ultralytics/yolov5/releases/download/v3.0/yolov5s.pt')
|
||||
#import torch
|
||||
#td = torch.load(io.BytesIO(dat))
|
||||
#print(td)
|
||||
#dat = fetch('https://github.com/ultralytics/yolov5/releases/download/v3.0/yolov5m.pt')
|
||||
|
||||
import zipfile
|
||||
fp = zipfile.ZipFile(io.BytesIO(dat))
|
||||
#fp.printdir()
|
||||
data = fp.read('archive/data.pkl')
|
||||
|
||||
#import pickletools
|
||||
#pickletools.dis(io.BytesIO(data))
|
||||
|
||||
# yolo specific
|
||||
ret, out = my_unpickle(io.BytesIO(data))
|
||||
print(dir(ret['model']))
|
||||
for m in ret['model']._modules['model']:
|
||||
print(m)
|
||||
print(m._modules.keys())
|
||||
d = ret['model'].yaml
|
||||
for i, (f, n, m, args) in enumerate(d['backbone'] + d['head']):
|
||||
tm = ret['model']._modules['model'][i]
|
||||
print(i, f, n, m, args, tm._modules.keys())
|
||||
# Focus, Conv, BottleneckCSP, SPP, Concat, Detect
|
||||
#for k,v in tm._modules.items():
|
||||
# print(" ", k, v)
|
||||
if m in "Focus":
|
||||
conv = tm._modules['conv']
|
||||
print(" ", conv._modules)
|
||||
if m in "Conv":
|
||||
conv, bn = tm._modules['conv'], tm._modules['bn']
|
||||
print(" ", conv)
|
||||
#print(bn)
|
||||
|
||||
|
||||
"""
|
||||
weights = fake_torch_load(data)
|
||||
for k,v in weights:
|
||||
print(k)
|
||||
"""
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# sorted in order of increasing complexity
|
||||
|
||||
import numpy as np
|
||||
from tinygrad.tensor import Tensor
|
||||
|
||||
class Optimizer:
|
||||
|
@ -25,7 +23,7 @@ class RMSprop(Optimizer):
|
|||
super().__init__(params)
|
||||
self.lr, self.decay, self.eps = lr, decay, eps
|
||||
|
||||
self.v = [Tensor(np.zeros(t.shape, dtype=np.float32), device=params[0].device, requires_grad=False) for t in self.params]
|
||||
self.v = [Tensor.zeros(*t.shape, device=params[0].device, requires_grad=False) for t in self.params]
|
||||
|
||||
def step(self):
|
||||
for i, t in enumerate(self.params):
|
||||
|
@ -37,8 +35,8 @@ class Adam(Optimizer):
|
|||
super().__init__(params)
|
||||
self.lr, self.b1, self.b2, self.eps, self.t = lr, b1, b2, eps, 0
|
||||
|
||||
self.m = [Tensor(np.zeros(t.shape, dtype=np.float32), device=params[0].device, requires_grad=False) for t in self.params]
|
||||
self.v = [Tensor(np.zeros(t.shape, dtype=np.float32), device=params[0].device, requires_grad=False) for t in self.params]
|
||||
self.m = [Tensor.zeros(*t.shape, device=params[0].device, requires_grad=False) for t in self.params]
|
||||
self.v = [Tensor.zeros(*t.shape, device=params[0].device, requires_grad=False) for t in self.params]
|
||||
|
||||
def step(self):
|
||||
self.t = self.t + 1
|
||||
|
|
Loading…
Reference in New Issue