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

MADE bias note #8

Open
TrentBrick opened this issue Jul 3, 2020 · 0 comments
Open

MADE bias note #8

TrentBrick opened this issue Jul 3, 2020 · 0 comments

Comments

@TrentBrick
Copy link

Not a bug as much as an important note for MADE which are producing deltas on the input:

For the output node where all of its input connections masked, the bias for this neuron should also be masked and currently is not. The code inside MaskedLinear should be changed as follows:

def set_mask(self, mask): # called when the masks are created. passes in this mask. 
    mask = torch.from_numpy(mask.astype(np.uint8).T)
    self.mask.data.copy_(mask)
    # if all of the inputs are zero, need to ensure the bias 
    # is zeroed out!
    self.bias_all_zero_mask = (mask.sum(dim=1)!=0).float()
    
def forward(self, input):
    return F.linear(input, self.mask * self.weight, self.bias_all_zero_mask * self.bias)```
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

1 participant