flowtorch
flowtorch copied to clipboard
Coupling layers
Adds Coupling layers.
### Test plan
from flowtorch.parameters.coupling import DenseCoupling, ConvCoupling
from flowtorch.bijectors.coupling import CouplingBijector as Coupling, ConvCouplingBijector
import torch
torch.set_default_dtype(torch.double)
def test():
d = DenseCoupling()
c = Coupling(d)
c = c(shape=torch.Size([32,]))
for p in c.parameters():
p.data += torch.randn_like(p)/10
x = torch.randn(1, 32,requires_grad=True)
y = c.forward(x)
yd = y.detach_from_flow()
x_bis = c.inverse(yd)
torch.testing.assert_allclose(x, x_bis)
torch.testing.assert_allclose(
c.log_abs_det_jacobian(x, y),
c.log_abs_det_jacobian(x, yd)
)
test()
Codecov Report
Merging #92 (54b4078) into main (4992731) will increase coverage by
0.04%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## main #92 +/- ##
==========================================
+ Coverage 98.25% 98.29% +0.04%
==========================================
Files 6 6
Lines 229 235 +6
==========================================
+ Hits 225 231 +6
Misses 4 4
Flag | Coverage Δ | |
---|---|---|
unittests | 98.29% <100.00%> (+0.04%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
tests/test_bijectivetensor.py | 98.64% <ø> (ø) |
|
tests/test_bijector.py | 100.00% <100.00%> (ø) |
|
tests/test_distribution.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 4992731...54b4078. Read the comment docs.