-
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.
Merge remote-tracking branch 'origin/dev' into dev
- Loading branch information
Showing
18 changed files
with
699 additions
and
342 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 |
---|---|---|
@@ -1,26 +1,33 @@ | ||
from copy import deepcopy | ||
|
||
import pytest | ||
import torch | ||
|
||
from torchflows import RNODE, Flow | ||
from torchflows import RNODE, Flow, Sylvester, RealNVP | ||
from torchflows.bijections.base import invert | ||
|
||
|
||
def test_basic(): | ||
@pytest.mark.parametrize('flow_class', [RNODE, Sylvester, RealNVP]) | ||
def test_basic(flow_class): | ||
torch.manual_seed(0) | ||
b = RNODE(event_shape=(10,)) | ||
b = flow_class(event_shape=(10,)) | ||
deepcopy(b) | ||
|
||
|
||
def test_post_variational_fit(): | ||
@pytest.mark.parametrize('flow_class', [RNODE, Sylvester, RealNVP]) | ||
def test_post_variational_fit(flow_class): | ||
torch.manual_seed(0) | ||
b = RNODE(event_shape=(10,)) | ||
b = flow_class(event_shape=(10,)) | ||
f = Flow(b) | ||
f.variational_fit(lambda x: torch.sum(-x ** 2), n_epochs=2) | ||
deepcopy(b) | ||
|
||
def test_post_fit(): | ||
@pytest.mark.parametrize('flow_class', [RNODE, Sylvester, RealNVP]) | ||
def test_post_fit(flow_class): | ||
torch.manual_seed(0) | ||
b = RNODE(event_shape=(10,)) | ||
b = flow_class(event_shape=(10,)) | ||
if isinstance(b, Sylvester): | ||
b = invert(b) | ||
f = Flow(b) | ||
f.fit(x_train=torch.randn(3, *b.event_shape), n_epochs=2) | ||
deepcopy(b) |
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
Oops, something went wrong.