Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test calculation of running variance in BatchNormedConv1d/Linear #322

Open
julianhoever opened this issue Sep 29, 2023 · 0 comments
Open

Comments

@julianhoever
Copy link
Contributor

Test the calculation of running variance in the BatchNormedConv1d and BatchNormedLinear (see the following integration test which fails):

@pytest.mark.parametrize(
"signal_length, inputs, expected",
[
(3, [1.0, 1.0, 1.0], [2.0, 2.0]),
(4, [0.5, 0.5, 1.0, 1.0], [1.0, 1.5, 2.0]),
],
)
def test_ones_weight_kernel_convolution(
signal_length: int, inputs: list[float], expected: list[float]
) -> None:
# TODO: Find out how the running_var calculation works?
# BatchNorm layer has a running_var of 0.25 for [1.0, 1.5, 2.0]
# But the correct running_var should be 0.166667
conv = conv1d(signal_length=signal_length, bias=False, affine=False)
conv.conv_weight.data = torch.ones_like(conv.conv_weight.data)
input_tensor = torch.tensor(inputs)
prediction = conv(input_tensor)
assert expected == prediction.tolist()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant