MokkeMeguru / TFGENZOO

Library about construction helper for Generative models e.g. Flow-based Model with Tensorflow 2.x.
https://mokkemeguru.github.io/TFGENZOO/
12 stars 2 forks source link

Any ways to pass constant into a flow component? #85

Closed gitlabspy closed 4 years ago

gitlabspy commented 4 years ago
for k in range(K):
                fml.append(Actnorm())
                fml.append(Inv1x1Conv())
                fml.append(
                    AffineCoupling(
                        mask_type=AffineCouplingMask.ChannelWise,
                        scale_shift_net_template=lambda x: ShallowResNet(
                            x, width=self.model_params["hidden_width"]
                        ),
                    )
                )
flows.append(FlowModule(fml))

Let's say x1 is a batch of imgs, I need to pass some kinda label thing x2 ,which is same size as x1 and unique to x1, to AffineCoupling to transform x1. Is there any way to achieve this?

MokkeMeguru commented 4 years ago

ConditionalAffincCoupling Layer can do so

MokkeMeguru commented 4 years ago

Take a 24 hour to implement the example...

gitlabspy commented 4 years ago

Thx! 😄

MokkeMeguru commented 4 years ago

https://github.com/MokkeMeguru/TFGENZOO/blob/master/tutorials/02_conditional_flow-based_model.ipynb is the tutorial to add conditional input into flow-based model.

(Please close the issue, if do it, I'll lose the issue...)

@gitlabspy

gitlabspy commented 4 years ago

Nice work! Thanks a lot! You mean I close it again? Or you want to keep this issue open?

MokkeMeguru commented 4 years ago

Your welcome If my answer is complete for you, please close it.

gitlabspy commented 4 years ago

Yeah, it totally solved my problem!