MCPcopy
hub / github.com/tinygrad/tinygrad / __init__

Method __init__

test/models/test_mnist.py:28–40  ·  view source on GitHub ↗
(self, has_batchnorm=False)

Source from the content-addressed store, hash-verified

26# create a model with a conv layer
27class TinyConvNet:
28 def __init__(self, has_batchnorm=False):
29 # https://keras.io/examples/vision/mnist_convnet/
30 conv = 3
31 #inter_chan, out_chan = 32, 64
32 inter_chan, out_chan = 8, 16 # for speed
33 self.c1 = Tensor.scaled_uniform(inter_chan,1,conv,conv)
34 self.c2 = Tensor.scaled_uniform(out_chan,inter_chan,conv,conv)
35 self.l1 = Tensor.scaled_uniform(out_chan*5*5, 10)
36 if has_batchnorm:
37 self.bn1 = BatchNorm2d(inter_chan)
38 self.bn2 = BatchNorm2d(out_chan)
39 else:
40 self.bn1, self.bn2 = lambda x: x, lambda x: x
41
42 def parameters(self):
43 return get_parameters(self)

Callers

nothing calls this directly

Calls 1

scaled_uniformMethod · 0.80

Tested by

no test coverage detected