Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'BatchNormFlow' object has no attribute 'batch_mean' in inverse mode #8

Closed
zhouhanc opened this issue Jan 7, 2019 · 1 comment

Comments

@zhouhanc
Copy link

zhouhanc commented Jan 7, 2019

I'm running into a problem when I call model.forward(..., mode='inverse') before calling model.forward(..., mode='direct'), in which case batch_mean and batch_var are not defined. What is a proper why to fix this problem? I need to use inverse mode first during the training stage in my application.

The code snippet looks like this. I've omitted some application specific codes.

block = [
fnn.MADE(num_inputs, num_hidden),
fnn.BatchNormFlow(num_inputs),
fnn.Reverse(num_inputs)
]
model = fnn.FlowSequential(*blocks)
model.train()
model.forward(..., mode='inverse')

AttributeError: 'BatchNormFlow' object has no attribute 'batch_mean'

@ikostrikov
Copy link
Owner

The easiest way to fix the problem would be to actually switch modes in BN.

Just replace 'direct' with 'inverse' here:
https://github.com/ikostrikov/pytorch-flows/blob/master/flows.py#L148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants