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

Neural sampling neurips2023 #212

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions neuralpredictors/layers/encoders/firing_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def __init__(
self.offset = elu_offset

if nonlinearity_type != "elu" and not np.isclose(elu_offset, 0.0):
warnings.warn("If `nonlinearity_type` is not 'elu', `elu_offset` will be ignored")
warnings.warn(
"If `nonlinearity_type` is not 'elu', `elu_offset` will be ignored"
)
if nonlinearity_type == "elu":
self.nonlinearity_fn = nn.ELU()
elif nonlinearity_type == "identity":
Expand Down Expand Up @@ -80,7 +82,7 @@ def forward(
x = self.modulator[data_key](x, behavior=behavior)

if self.nonlinearity_type == "elu":
return self.nonlinearity_fn(x + self.offset) + 1
return self.nonlinearity_fn(x) + 1 + self.offset
else:
return self.nonlinearity_fn(x)

Expand Down
4 changes: 2 additions & 2 deletions neuralpredictors/measures/zero_inflated_losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def forward(self, target, output, **kwargs):
if loc.requires_grad:
self.multi_clamp(loc, [0.0] * neurons_n, target.max(dim=0)[0])

zero_mask = target < loc
nonzero_mask = target >= loc
zero_mask = target <= loc
nonzero_mask = target > loc

# spike loss
spike_logl = torch.log(1 - q) - torch.log(loc)
Expand Down