add models and layers backward test

This commit is contained in:
cyberguli
2024-02-19 23:09:10 +01:00
committed by Nicola Demo
parent cbb43a5392
commit eb1af0b50e
10 changed files with 308 additions and 1 deletions

View File

@@ -24,3 +24,14 @@ def test_forward():
x = torch.rand(10, 2)
model = ResidualFeedForward(input_dimensions=2, output_dimensions=1)
model(x)
def test_backward():
x = torch.rand(10, 2)
x.requires_grad = True
model = ResidualFeedForward(input_dimensions=2, output_dimensions=1)
model(x)
l = torch.mean(model(x))
l.backward()
assert x.grad.shape == torch.Size([10, 2])