Skip to content

Commit

Permalink
Use NormalizedCheckerBoard coupling in the first layer of multiscale …
Browse files Browse the repository at this point in the history
…architectures to handle single channel images
  • Loading branch information
davidnabergoj committed Aug 30, 2024
1 parent dcbb653 commit 5af9853
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion torchflows/bijections/finite/multiscale/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,20 @@ def __init__(self,
Type[NormalizedChannelWiseCoupling],
Type[GlowChannelWiseCoupling]
] = NormalizedChannelWiseCoupling,
first_layer: bool = True,
**kwargs):
if n_blocks < 1:
raise ValueError
super().__init__(event_shape, **kwargs)

self.n_blocks = n_blocks

if first_layer and checkerboard_class == GlowCheckerboardCoupling:
layer_checkerboard_class = NormalizedCheckerboardCoupling # Compatibility with single channel images
else:
layer_checkerboard_class = checkerboard_class
self.checkerboard_layers = nn.ModuleList([
checkerboard_class(
layer_checkerboard_class(
event_shape,
transformer_class=transformer_class,
alternate=i % 2 == 1,
Expand Down Expand Up @@ -269,6 +275,7 @@ def __init__(self,
event_shape=small_event_shape,
transformer_class=transformer_class,
n_blocks=self.n_blocks - 1,
first_layer=False,
**kwargs
)

Expand Down

0 comments on commit 5af9853

Please sign in to comment.