Merged
Conversation
Member
|
Please rebase commit to resolve conflicts. |
l-bat
reviewed
Aug 17, 2020
l-bat
reviewed
Aug 17, 2020
Comment on lines
+909
to
+929
| class MatmulWithTwoInputs(nn.Module): | ||
| def __init__(self, in_dim = 2, const_dim=2, interm_dim = 2): | ||
| super(MatmulWithTwoInputs, self).__init__() | ||
| self.in_dim = in_dim | ||
| self.const_dim = const_dim | ||
| self.interm_dim = interm_dim | ||
| self.linear_for_const = nn.Linear(const_dim, interm_dim) | ||
| self.first_linear = nn.Linear(in_dim, interm_dim) | ||
| self.second_linear = nn.Linear(interm_dim, 1) | ||
| def forward(self, x): | ||
| x = x.reshape(-1, self.in_dim) | ||
| x_projected = self.first_linear(x) | ||
| const = torch.zeros(1, self.interm_dim) | ||
| const_projected = self.linear_for_const(const) | ||
| const_projected = const_projected.expand(2, self.interm_dim) | ||
| sum_tanh = torch.tanh(const_projected + x_projected) | ||
| sum_tanh = sum_tanh.reshape(-1, self.interm_dim) | ||
| sum_tanh_projected = self.second_linear(sum_tanh) | ||
| sum_tanh_projected = sum_tanh_projected.reshape(1, 2) | ||
| after_softmax = F.softmax(sum_tanh_projected, dim=1) | ||
| return torch.matmul(after_softmax, x) |
Contributor
There was a problem hiding this comment.
Do we really need such a large subgraph? Maybe you can cover your changes in the onnx importer using just one matrix multiplication?
Contributor
Author
There was a problem hiding this comment.
Unfortunately, it does not reproduce that way
b6e40af to
e71619b
Compare
Member
|
Please do not use merge commits in PRs to resolve conflicts. There are several artifacts during PR merge which requires extra changes: |
Merged
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Data for PR opencv/opencv#17978