-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor classic residual bijections
- Loading branch information
1 parent
a510134
commit 3bc85b0
Showing
9 changed files
with
108 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
import torch | ||
|
||
from torchflows.flows import Flow | ||
from torchflows.bijections.finite.residual.architectures import RadialFlow, SylvesterFlow, PlanarFlow | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'architecture_class', | ||
[ | ||
RadialFlow, | ||
SylvesterFlow, | ||
PlanarFlow | ||
] | ||
) | ||
def test_basic(architecture_class): | ||
torch.manual_seed(0) | ||
event_shape = (1, 2, 3, 4) | ||
batch_shape = (5, 6) | ||
|
||
flow = Flow(architecture_class(event_shape)) | ||
x_new = flow.sample(batch_shape) | ||
assert x_new.shape == (*batch_shape, *event_shape) | ||
|
||
flow.bijection.invert() | ||
assert flow.log_prob(x_new).shape == batch_shape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters