flowtorch icon indicating copy to clipboard operation
flowtorch copied to clipboard

[WIP] Conv1x1

Open vmoens opened this issue 2 years ago • 0 comments

Motivation

Proposes a 1x1 convolution bijector.

Test Plan

from flowtorch.bijectors import Conv1x1Bijector
import torch


def test(LU_decompose, zero_init):
    c = Conv1x1Bijector(LU_decompose=LU_decompose, zero_init=zero_init)
    c = c(shape=torch.Size([10, 20, 20]))
    for p in c.parameters():
        p.data += torch.randn_like(p)/5

    x = torch.randn(1, 10, 20, 20)
    y = c.forward(x)
    yp = y.detach_from_flow()
    xp = c.inverse(yp)
    assert (xp/x-1).norm() < 1e-2

    assert (xp-x).norm()
    
for LU_decompose in (True, False):
    for zero_init in (True, False):
        test(True, True)

Important

This PR is branched out from the coupling layer. I'll update the branch once the review of the coupling layer is completed.

vmoens avatar Apr 26 '22 15:04 vmoens