MCPcopy
hub / github.com/tinygrad/tinygrad / test_mnist_backward

Method test_mnist_backward

test/test_tiny.py:135–146  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

133 # TODO: this is failing because of how swizzling rewrites the ShapeTracker of the final STORE
134 @unittest.skipIf(CI and Device.DEFAULT == "DSP", "failing because of make things that can't be images not images")
135 def test_mnist_backward(self):
136 # NOTE: we don't have the whole model here for speed
137 layers = [
138 nn.Conv2d(1, 8, 5), Tensor.relu,
139 nn.Conv2d(8, 8, 5), Tensor.relu]
140
141 # replace random weights with ones
142 Tensor.realize(*[p.replace(Tensor.ones_like(p).contiguous()) for p in nn.state.get_parameters(layers)])
143
144 # realize gradients
145 Tensor.empty(4, 1, 14, 14).sequential(layers).sum().backward()
146 Tensor.realize(*[x.grad for x in nn.state.get_parameters(layers) if x.grad is not None])
147
148 # *** image ***
149

Callers 1

mnist_backwardFunction · 0.80

Calls 9

realizeMethod · 0.80
ones_likeMethod · 0.80
sumMethod · 0.80
sequentialMethod · 0.80
replaceMethod · 0.45
contiguousMethod · 0.45
get_parametersMethod · 0.45
backwardMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected