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

@@ -35,3 +35,12 @@ def test_forward():
fnn = FeedForward(dim_in, dim_out)
output_ = fnn(data)
assert output_.shape == (data.shape[0], dim_out)
def test_backward():
dim_in, dim_out = 3, 2
fnn = FeedForward(dim_in, dim_out)
data.requires_grad = True
output_ = fnn(data)
l=torch.mean(output_)
l.backward()
assert data._grad.shape == torch.Size([20,3])