-
Notifications
You must be signed in to change notification settings - Fork 7
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
Refactor bookkeeping #105
Merged
Merged
Refactor bookkeeping #105
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
edecc1e
new bookkeeping
loreloc 82d2a6b
probabilities now sum up to one
loreloc 6b980db
fix linting errors
loreloc 1dd0ef6
prevent concatenating tensors if network is feed-forward
loreloc 7fb7359
tests passing
loreloc 1589bac
Merge branch 'main' into refactor-bookkeeping
loreloc 819572a
fix comment
loreloc 7297caa
Merge branch 'main' into refactor-bookkeeping
loreloc 1ed21c4
removed unused fold_count attribute from layers
loreloc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,13 +67,14 @@ def _forward_linear(self, left: Tensor, right: Tensor) -> Tensor: | |
right_hidden = self._forward_right_linear(right) | ||
return self._forward_out_linear(left_hidden * right_hidden) | ||
|
||
def forward(self, log_left: Tensor, log_right: Tensor) -> Tensor: # type: ignore[override] | ||
def forward(self, inputs: Tensor) -> Tensor: # type: ignore[override] | ||
"""Compute the main Einsum operation of the layer. | ||
|
||
:param log_left: value in log space for left child. | ||
:param log_right: value in log space for right child. | ||
:param inputs: value in log space for left child. | ||
:return: result of the left operations, in log-space. | ||
""" | ||
log_left, log_right = inputs[:, 0], inputs[:, 1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these two are non-contiguous inputs for the following. however seems no major performance impact for CP? yet we don't know if this will harm other layers, so if no performance difference, we should use contiguous. |
||
|
||
# TODO: do we split into two impls? | ||
if self.prod_exp: | ||
return log_func_exp(log_left, log_right, func=self._forward_linear, dim=1, keepdim=True) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong about this